From 34d800ba2373ba8a6b0ac9ef5da1dacebf3c599d Mon Sep 17 00:00:00 2001 From: liuxinxin Date: Mon, 20 Feb 2023 17:29:03 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=BC=96=E8=BE=91=20?= =?UTF-8?q?=E5=8F=8A=E7=94=A8=E6=88=B7=E7=A6=81=E7=94=A8=E5=90=AF=E7=94=A8?= =?UTF-8?q?=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/user/manage/UserInfoManage.java | 22 ++++++++++++++++++++-- pmapi/src/main/resources/security/auth-dev.yml | 1 + 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java index a03aa5c..fcee3b0 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java @@ -10,7 +10,9 @@ import com.ningdatech.basic.model.PageVo; import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo; import com.ningdatech.pmapi.organization.service.IDingEmployeeInfoService; import com.ningdatech.pmapi.organization.service.IDingOrganizationService; +import com.ningdatech.pmapi.sys.model.entity.Role; import com.ningdatech.pmapi.sys.model.entity.UserRole; +import com.ningdatech.pmapi.sys.service.IRoleService; import com.ningdatech.pmapi.sys.service.IUserRoleService; import com.ningdatech.pmapi.user.constant.UserAvailableEnum; import com.ningdatech.pmapi.user.entity.UserInfo; @@ -44,6 +46,7 @@ public class UserInfoManage { private final IDingEmployeeInfoService iDingEmployeeInfoService; private final IUserInfoService iUserInfoService; private final IUserRoleService iUserRoleService; + private final IRoleService iRoleService; public PageVo list(ReqUserInfoListPO reqUserInfoListPO) { LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(DingEmployeeInfo.class) @@ -99,7 +102,21 @@ public class UserInfoManage { resUserDetailVO.setUserId(userInfo.getId()); resUserDetailVO.setPhoneNo(userInfo.getMobile()); resUserDetailVO.setStatus(userInfo.getAvailable()); - resUserDetailVO.setUserRoleInfoList(new ArrayList<>()); + + // 装配用户角色信息列表 + List userRoleList = iUserRoleService.list(Wrappers.lambdaQuery(UserRole.class).eq(UserRole::getUserId, userId)); + List userRoleInfoList = new ArrayList<>(); + if (CollUtil.isNotEmpty(userRoleList)) { + List roleIdList = userRoleList.stream().map(UserRole::getRoleId).collect(Collectors.toList()); + List 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; } @@ -129,7 +146,8 @@ public class UserInfoManage { } - private Long generateUserId(String employeeCode) { + @Transactional(rollbackFor = Exception.class) + public Long generateUserId(String employeeCode) { UserInfo userInfo = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) .eq(UserInfo::getEmployeeCode, employeeCode)); if (Objects.isNull(userInfo)) { diff --git a/pmapi/src/main/resources/security/auth-dev.yml b/pmapi/src/main/resources/security/auth-dev.yml index 2781c2c..c22582d 100644 --- a/pmapi/src/main/resources/security/auth-dev.yml +++ b/pmapi/src/main/resources/security/auth-dev.yml @@ -22,6 +22,7 @@ security: - /oa/** - /wflow/** - /sys/** + - /api/v1/user-info/** ignore-csrf-urls: - /api/v1/user/auth/** - /v2/api-docs