package com.landtool.lanbase.modules.api.controller;
|
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiParam;
|
|
import java.io.IOException;
|
import java.util.HashMap;
|
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;
|
import com.landtool.lanbase.common.utils.ComplexPropertyPreFilter;
|
import com.landtool.lanbase.common.utils.IPUtils;
|
import com.landtool.lanbase.modules.log.service.LogActionService;
|
import com.landtool.lanbase.modules.org.entity.OrgUserGroup;
|
import com.landtool.lanbase.modules.org.entity.OrgUserJoinUnit;
|
import com.landtool.lanbase.modules.org.entity.OrgUserunit;
|
import com.landtool.lanbase.modules.sys.entity.SysUserToken;
|
import com.landtool.lanbase.modules.sys.service.SysUserTokenService;
|
|
/**
|
* @Description: 系统模块操作日志提供的api
|
*
|
*/
|
@Controller
|
@RequestMapping(path = "/api/sys/usertoken")
|
@Api(value = "", tags = {"用户token相关接口"})
|
public class SysUserTokenApiController {
|
|
@Autowired
|
private SysUserTokenService userTokenService;
|
|
/*
|
* 根据用户id查询token信息
|
*/
|
@GetMapping(path="/getInfoByUserId/{userId}")
|
@ApiOperation(
|
value = "根据用户id查询token",
|
notes = ""
|
)
|
public void getInfoByUserId(@ApiParam(name="userId",value="用户Id",required=true)
|
@PathVariable(name = "userId")Long userId ,
|
HttpServletResponse response) throws IOException {
|
SimplePropertyPreFilter filter = new SimplePropertyPreFilter();
|
filter.getExcludes().add("rcreatedate");
|
filter.getExcludes().add("rcreateuser");
|
|
response.setHeader("Content-Type","application/json;charset=UTF-8");
|
response.getWriter().write(JSONObject.toJSONString(userTokenService.queryByUserId(userId),filter));
|
}
|
|
/*
|
* 根据token查询token信息
|
*/
|
@GetMapping(path="/getInfoByToken/{token}")
|
@ApiOperation(
|
value = "根据token查询token信息",
|
notes = ""
|
)
|
public void getInfoByToken(@ApiParam(name="token",value="token",required=true)
|
@PathVariable(name = "token")String token ,
|
HttpServletResponse response) throws IOException {
|
SimplePropertyPreFilter filter = new SimplePropertyPreFilter();
|
filter.getExcludes().add("rcreatedate");
|
filter.getExcludes().add("rcreateuser");
|
|
response.setHeader("Content-Type","application/json;charset=UTF-8");
|
response.getWriter().write(JSONObject.toJSONString(userTokenService.queryByToken(token),filter));
|
}
|
|
/*
|
* token信息写入
|
*/
|
@PostMapping(path="/addUserToken")
|
@ApiOperation(
|
value = "token信息写入",
|
notes = ""
|
)
|
@ResponseBody
|
public String addUserToken(@ApiParam(name="userId",value="用户Id",required=true)
|
@RequestParam(name = "userId")Long userId,
|
@ApiParam(name="loginname",value="用户登录名",required=true)
|
@RequestParam(name = "loginname")String loginname,
|
@ApiParam(name="token",value="token",required=true)
|
@RequestParam(name = "token")String token,
|
@ApiParam(name="expireTime",value="过期时间",required=true)
|
@RequestParam(name = "expireTime")String expireTime,
|
@ApiParam(name="updateTime",value="更新时间",required=true)
|
@RequestParam(name = "updateTime")String updateTime){
|
|
userTokenService.addUserToken(userId,loginname,token,expireTime,updateTime);
|
|
return "添加成功";
|
|
}
|
|
/*
|
* token信息修改
|
*/
|
@PostMapping(path="/updateUserToken")
|
@ApiOperation(
|
value = "token信息修改",
|
notes = ""
|
)
|
@ResponseBody
|
public String updateUserToken(@ApiParam(name="userId",value="用户Id",required=true)
|
@RequestParam(name = "userId")Long userId,
|
@ApiParam(name="loginname",value="用户登录名",required=true)
|
@RequestParam(name = "loginname")String loginname,
|
@ApiParam(name="token",value="token",required=true)
|
@RequestParam(name = "token")String token,
|
@ApiParam(name="expireTime",value="过期时间",required=true)
|
@RequestParam(name = "expireTime")String expireTime,
|
@ApiParam(name="updateTime",value="更新时间",required=true)
|
@RequestParam(name = "updateTime")String updateTime){
|
|
userTokenService.updateUserToken(userId,loginname,token,expireTime,updateTime);
|
|
return "修改成功";
|
|
}
|
}
|