mirror of https://gitee.com/stylefeng/roses
【8.1.0】【role】更新登录用户获取角色的方法
parent
4192ca6b04
commit
8f2013dc8e
|
@ -153,10 +153,6 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUs
|
|||
@Override
|
||||
public List<Long> getUserRoleIdListCurrentCompany(Long userId, Long companyId) {
|
||||
|
||||
if (ObjectUtil.isEmpty(companyId)) {
|
||||
return this.getUserRoleIdList(userId);
|
||||
}
|
||||
|
||||
// 先从缓存查找用户的角色
|
||||
List<SysUserRole> cachedRoleList = userRoleCache.get(userId.toString());
|
||||
if (ObjectUtil.isNotEmpty(cachedRoleList)) {
|
||||
|
@ -274,6 +270,11 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUs
|
|||
Set<Long> baseRoleIdList = paramRoles.stream().filter(i -> RoleTypeEnum.SYSTEM_ROLE.getCode().equals(i.getRoleType()) && i.getRoleCompanyId() == null).map(SysUserRole::getRoleId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 没传当前公司id,则只返回最基本的角色
|
||||
if (ObjectUtil.isEmpty(userCurrentCompanyId)) {
|
||||
return new ArrayList<>(baseRoleIdList);
|
||||
}
|
||||
|
||||
// 2. 获取用户当前登录公司下的角色id集合
|
||||
Set<Long> currentCompanyRoleIdList = paramRoles.stream()
|
||||
.filter(i -> RoleTypeEnum.COMPANY_ROLE.getCode().equals(i.getRoleType())
|
||||
|
|
|
@ -258,8 +258,15 @@ public class UserIndexInfoService {
|
|||
|
||||
Long userId = loginUser.getUserId();
|
||||
|
||||
// 获取用户的角色集合
|
||||
List<Long> roleIdList = sysUserRoleServiceApi.getUserRoleIdList(userId);
|
||||
List<Long> roleIdList = null;
|
||||
|
||||
// 获取用户当前公司下的角色集合
|
||||
List<Long> userCurrentCompanyList = userIndexInfo.getUserOrgInfoList().stream().filter(IndexUserOrgInfo::getCurrentSelectFlag).map(IndexUserOrgInfo::getCompanyId).collect(Collectors.toList());
|
||||
if (ObjectUtil.isEmpty(userCurrentCompanyList)) {
|
||||
roleIdList = sysUserRoleServiceApi.getUserRoleIdListCurrentCompany(userId, null);
|
||||
} else {
|
||||
roleIdList = sysUserRoleServiceApi.getUserRoleIdListCurrentCompany(userId, userCurrentCompanyList.get(0));
|
||||
}
|
||||
|
||||
if (ObjectUtil.isEmpty(roleIdList)) {
|
||||
userIndexInfo.setPermissionCodeList(new HashSet<>());
|
||||
|
|
Loading…
Reference in New Issue