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 0cd3b9f..d974830 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,6 +10,7 @@ import com.ningdatech.basic.model.PageVo; import com.ningdatech.pmapi.common.constant.RegionConst; import com.ningdatech.pmapi.common.helper.RegionCacheHelper; import com.ningdatech.pmapi.common.helper.UserInfoHelper; +import com.ningdatech.pmapi.common.util.BizUtils; import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo; import com.ningdatech.pmapi.organization.model.entity.DingOrganization; import com.ningdatech.pmapi.organization.service.IDingEmployeeInfoService; @@ -206,7 +207,7 @@ public class UserInfoManage { return new ArrayList<>(); } return iUserInfoService.list(Wrappers.lambdaQuery(UserInfo.class) - .in(UserInfo::getId, compliantUserIdList)) + .in(UserInfo::getId, compliantUserIdList)) .stream().map(UserInfo::getId).collect(Collectors.toList()); } @@ -497,4 +498,42 @@ public class UserInfoManage { return processInstanceUserDto; } + /** + * 获取当前用户可控角色列表 + * + * @return + */ + public List getControlledRoleList() { + Long userId = LoginUserUtil.getUserId(); + // 装配用户角色信息列表 + List userRoleList = iUserRoleService.list(Wrappers.lambdaQuery(UserRole.class) + .eq(UserRole::getUserId, userId)); + + List controlledRoleVOList = new ArrayList<>(); + List controlledRoleIdList = new ArrayList<>(); + if (CollUtil.isNotEmpty(userRoleList)) { + List roleIdList = userRoleList.stream().map(UserRole::getRoleId).distinct().collect(Collectors.toList()); + controlledRoleIdList.addAll(roleIdList); + List roleList = iRoleService.list(Wrappers.lambdaQuery(Role.class).in(Role::getId, roleIdList)); + + for (Role role : roleList) { + List manageRoleIdList = BizUtils.splitToLong(role.getManageRoleIds()); + if (CollUtil.isNotEmpty(manageRoleIdList)) { + controlledRoleIdList.addAll(manageRoleIdList); + } + } + controlledRoleIdList = controlledRoleIdList.stream().distinct().collect(Collectors.toList()); + List controlledRoleList = iRoleService.list(Wrappers.lambdaQuery(Role.class).in(Role::getId, controlledRoleIdList)); + + controlledRoleVOList = controlledRoleList.stream().map(r -> { + UserRoleVO userRoleVO = new UserRoleVO(); + userRoleVO.setId(r.getId()); + userRoleVO.setName(r.getName()); + userRoleVO.setCode(r.getCode()); + return userRoleVO; + }).collect(Collectors.toList()); + } + return controlledRoleVOList; + } + }