Commit fb517438 authored by ma's avatar ma

修改获取用户信息接口

parent 05425b4a
...@@ -6,7 +6,6 @@ import io.swagger.annotations.Api; ...@@ -6,7 +6,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import iot.sixiang.license.consts.ResultCode; import iot.sixiang.license.consts.ResultCode;
import iot.sixiang.license.entity.User; import iot.sixiang.license.entity.User;
import iot.sixiang.license.entity.UserPermission;
import iot.sixiang.license.jwt.JwtUtil; import iot.sixiang.license.jwt.JwtUtil;
import iot.sixiang.license.jwt.LoginUser; import iot.sixiang.license.jwt.LoginUser;
import iot.sixiang.license.jwt.UserUtils; import iot.sixiang.license.jwt.UserUtils;
...@@ -32,7 +31,6 @@ import springfox.documentation.annotations.ApiIgnore; ...@@ -32,7 +31,6 @@ import springfox.documentation.annotations.ApiIgnore;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.ServletRequest; import javax.servlet.ServletRequest;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* 登录Controller * 登录Controller
...@@ -100,10 +98,8 @@ public class LoginController { ...@@ -100,10 +98,8 @@ public class LoginController {
// if (code.equals(UserUtils.getEmailCode(userName)) && curCodeDate.before(UserUtils.getEmailCodeExpTime(userName))) { // if (code.equals(UserUtils.getEmailCode(userName)) && curCodeDate.before(UserUtils.getEmailCodeExpTime(userName))) {
if (code.equals("123456")) { if (code.equals("123456")) {
String token = JwtUtil.createToken(dbUser); String token = JwtUtil.createToken(dbUser);
List<UserPermission> permissions = userPermissionService.getPermissionById(user.getUserId());
LoginVo loginVo = new LoginVo(); LoginVo loginVo = new LoginVo();
loginVo.setAuthorization(token); loginVo.setAuthorization(token);
loginVo.setPermissionList(permissions);
loginVo.setUpdateTime(user.getUpdateTime()); loginVo.setUpdateTime(user.getUpdateTime());
UserUtils.setToken(dbUser.getUserId(), token); UserUtils.setToken(dbUser.getUserId(), token);
UserUtils.setTokenExp(dbUser.getUserId(), JwtUtil.getTokenExp()); UserUtils.setTokenExp(dbUser.getUserId(), JwtUtil.getTokenExp());
......
package iot.sixiang.license.controller; package iot.sixiang.license.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.Validator; import cn.hutool.core.lang.Validator;
import com.acc.secret.util.RSAUtil; import com.acc.secret.util.RSAUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -25,6 +26,7 @@ import iot.sixiang.license.model.ResResult; ...@@ -25,6 +26,7 @@ import iot.sixiang.license.model.ResResult;
import iot.sixiang.license.model.dto.AssignUserPermissionDTO; import iot.sixiang.license.model.dto.AssignUserPermissionDTO;
import iot.sixiang.license.model.dto.UpdateNotifyDTO; import iot.sixiang.license.model.dto.UpdateNotifyDTO;
import iot.sixiang.license.model.vo.UserDeleteVO; import iot.sixiang.license.model.vo.UserDeleteVO;
import iot.sixiang.license.model.vo.UserDetailVO;
import iot.sixiang.license.model.vo.UserUpdatePwdVo; import iot.sixiang.license.model.vo.UserUpdatePwdVo;
import iot.sixiang.license.model.vo.UserVo; import iot.sixiang.license.model.vo.UserVo;
import iot.sixiang.license.service.PermissionService; import iot.sixiang.license.service.PermissionService;
...@@ -253,13 +255,21 @@ public class UserController { ...@@ -253,13 +255,21 @@ public class UserController {
@ApiOperation(value = "获取用户信息接口", notes = "获取用户信息") @ApiOperation(value = "获取用户信息接口", notes = "获取用户信息")
@GetMapping("get") @GetMapping("get")
@MyLog(title = "获取用户信息", businessType = BusinessType.SELECT) @MyLog(title = "获取用户信息", businessType = BusinessType.SELECT)
public ResResult<User> getUserPermissionList() { public ResResult<UserDetailVO> getUserPermissionList() {
String userId = UserUtils.getLoginUserId(); String userId = UserUtils.getLoginUserId();
if (StringUtils.isEmpty(userId)) { if (StringUtils.isEmpty(userId)) {
return ResResult.failed().setMsgValue("请重新登录"); return ResResult.failed().setMsgValue("请重新登录");
} }
User user = userService.getUserById(Integer.parseInt(userId)); User user = userService.getUserById(Integer.parseInt(userId));
return ResResult.success().goRecord(user); if (user == null) {
return ResResult.failed();
} else {
List<UserPermission> permissions = userPermissionService.getPermissionById(user.getUserId());
UserDetailVO userDetailVO = new UserDetailVO();
BeanUtil.copyProperties(user, userDetailVO);
userDetailVO.setPermissionList(permissions);
return ResResult.success().goRecord(userDetailVO);
}
} }
......
package iot.sixiang.license.model.vo; package iot.sixiang.license.model.vo;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import iot.sixiang.license.entity.Permission;
import iot.sixiang.license.entity.UserPermission;
import lombok.Data; import lombok.Data;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* Created by m33 on 2022/6/14 18:51 * Created by m33 on 2022/6/14 18:51
...@@ -17,9 +14,6 @@ public class LoginVo { ...@@ -17,9 +14,6 @@ public class LoginVo {
@ApiModelProperty("token") @ApiModelProperty("token")
private String authorization; private String authorization;
@ApiModelProperty("用户权限列表")
private List<UserPermission> permissionList;
@ApiModelProperty("更新时间") @ApiModelProperty("更新时间")
private Date updateTime; private Date updateTime;
} }
package iot.sixiang.license.model.vo;
import io.swagger.annotations.ApiModelProperty;
import iot.sixiang.license.entity.User;
import iot.sixiang.license.entity.UserPermission;
import lombok.Data;
import java.util.List;
/**
* Created by m33
* Date 2023/2/2 16:53
* Description
*/
@Data
public class UserDetailVO extends User {
@ApiModelProperty("用户权限列表")
private List<UserPermission> permissionList;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment