Browse Source

fix 获取当前登陆用户详情信息

tags/24080901
liuxinxin 1 year ago
parent
commit
44f1105ad1
2 changed files with 47 additions and 11 deletions
  1. +26
    -9
      pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java
  2. +21
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/user/model/vo/ResUserDetailVO.java

+ 26
- 9
pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java View File

@@ -15,24 +15,17 @@ import com.ningdatech.pmapi.sys.model.entity.Role;
import com.ningdatech.pmapi.sys.model.entity.UserRole; import com.ningdatech.pmapi.sys.model.entity.UserRole;
import com.ningdatech.pmapi.sys.service.IRoleService; import com.ningdatech.pmapi.sys.service.IRoleService;
import com.ningdatech.pmapi.sys.service.IUserRoleService; import com.ningdatech.pmapi.sys.service.IUserRoleService;
import com.ningdatech.pmapi.user.constant.LoginTypeEnum;
import com.ningdatech.pmapi.user.constant.UserAvailableEnum; import com.ningdatech.pmapi.user.constant.UserAvailableEnum;
import com.ningdatech.pmapi.user.entity.UserInfo; import com.ningdatech.pmapi.user.entity.UserInfo;
import com.ningdatech.pmapi.user.model.po.*; import com.ningdatech.pmapi.user.model.po.*;
import com.ningdatech.pmapi.user.model.vo.ResUserDetailVO; import com.ningdatech.pmapi.user.model.vo.ResUserDetailVO;
import com.ningdatech.pmapi.user.model.vo.ResUserInfoListVO; import com.ningdatech.pmapi.user.model.vo.ResUserInfoListVO;
import com.ningdatech.pmapi.user.model.vo.UserRoleVO; import com.ningdatech.pmapi.user.model.vo.UserRoleVO;
import com.ningdatech.pmapi.user.security.auth.constants.UserDeatilsServiceConstant;
import com.ningdatech.pmapi.user.security.auth.credential.CredentialAuthToken;
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO;
import com.ningdatech.pmapi.user.service.IUserInfoService; import com.ningdatech.pmapi.user.service.IUserInfoService;
import com.ningdatech.pmapi.user.util.LoginUserUtil; import com.ningdatech.pmapi.user.util.LoginUserUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.web.authentication.WebAuthenticationDetails;
import org.springframework.security.web.context.HttpSessionSecurityContextRepository;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;


@@ -232,8 +225,32 @@ public class UserInfoManage {


public ResUserDetailVO currentUserInfo() { public ResUserDetailVO currentUserInfo() {
Long userId = LoginUserUtil.getUserId(); Long userId = LoginUserUtil.getUserId();
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId);
return null;
UserInfo userInfo = iUserInfoService.getById(userId);
if (Objects.isNull(userInfo)) {
return null;
}
ResUserDetailVO resUserDetailVO = new ResUserDetailVO();
resUserDetailVO.setRealName(userInfo.getRealName());
resUserDetailVO.setUserId(userInfo.getId());
resUserDetailVO.setPhoneNo(userInfo.getMobile());
resUserDetailVO.setStatus(userInfo.getAvailable());

// 装配用户角色信息列表
List<UserRole> userRoleList = iUserRoleService.list(Wrappers.lambdaQuery(UserRole.class)
.eq(UserRole::getUserId, userId));
List<UserRoleVO> userRoleInfoList = new ArrayList<>();
if (CollUtil.isNotEmpty(userRoleList)) {
List<Long> roleIdList = userRoleList.stream().map(UserRole::getRoleId).collect(Collectors.toList());
List<Role> roleList = iRoleService.list(Wrappers.lambdaQuery(Role.class).in(Role::getId, roleIdList));
userRoleInfoList = roleList.stream().map(r -> {
UserRoleVO userRoleVO = new UserRoleVO();
userRoleVO.setId(r.getId());
userRoleVO.setName(r.getName());
return userRoleVO;
}).collect(Collectors.toList());
}
resUserDetailVO.setUserRoleInfoList(userRoleInfoList);
return resUserDetailVO;
} }


public void generationLogin(ReqGenerationLoginPO reqGenerationLoginPO) { public void generationLogin(ReqGenerationLoginPO reqGenerationLoginPO) {


+ 21
- 2
pmapi/src/main/java/com/ningdatech/pmapi/user/model/vo/ResUserDetailVO.java View File

@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;


import java.time.LocalDateTime;
import java.util.List; import java.util.List;


/** /**
@@ -23,9 +24,27 @@ public class ResUserDetailVO {
@ApiModelProperty("手机号") @ApiModelProperty("手机号")
private String phoneNo; private String phoneNo;


@ApiModelProperty("用户角色信息列表")
private List<UserRoleVO> userRoleInfoList;

@ApiModelProperty("浙政钉 用户编码")
private String employeeCode;

@ApiModelProperty("所在单位(主职)")
private String orgName;

@ApiModelProperty("所在单位(主职)code")
private String orgCode;

@ApiModelProperty("所属区域")
private Long regionId;

@ApiModelProperty("用户角色")
private List<UserRoleVO> userRoleList;

@ApiModelProperty("状态 启用 ENABLE/禁用 DISABLE") @ApiModelProperty("状态 启用 ENABLE/禁用 DISABLE")
private String status; private String status;


@ApiModelProperty("用户角色信息列表")
private List<UserRoleVO> userRoleInfoList;
@ApiModelProperty("更新时间")
private LocalDateTime updateTime;
} }

Loading…
Cancel
Save