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
|
@Override
|
||||||
public List<Long> getUserRoleIdListCurrentCompany(Long userId, Long companyId) {
|
public List<Long> getUserRoleIdListCurrentCompany(Long userId, Long companyId) {
|
||||||
|
|
||||||
if (ObjectUtil.isEmpty(companyId)) {
|
|
||||||
return this.getUserRoleIdList(userId);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 先从缓存查找用户的角色
|
// 先从缓存查找用户的角色
|
||||||
List<SysUserRole> cachedRoleList = userRoleCache.get(userId.toString());
|
List<SysUserRole> cachedRoleList = userRoleCache.get(userId.toString());
|
||||||
if (ObjectUtil.isNotEmpty(cachedRoleList)) {
|
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)
|
Set<Long> baseRoleIdList = paramRoles.stream().filter(i -> RoleTypeEnum.SYSTEM_ROLE.getCode().equals(i.getRoleType()) && i.getRoleCompanyId() == null).map(SysUserRole::getRoleId)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
// 没传当前公司id,则只返回最基本的角色
|
||||||
|
if (ObjectUtil.isEmpty(userCurrentCompanyId)) {
|
||||||
|
return new ArrayList<>(baseRoleIdList);
|
||||||
|
}
|
||||||
|
|
||||||
// 2. 获取用户当前登录公司下的角色id集合
|
// 2. 获取用户当前登录公司下的角色id集合
|
||||||
Set<Long> currentCompanyRoleIdList = paramRoles.stream()
|
Set<Long> currentCompanyRoleIdList = paramRoles.stream()
|
||||||
.filter(i -> RoleTypeEnum.COMPANY_ROLE.getCode().equals(i.getRoleType())
|
.filter(i -> RoleTypeEnum.COMPANY_ROLE.getCode().equals(i.getRoleType())
|
||||||
|
|
|
@ -258,8 +258,15 @@ public class UserIndexInfoService {
|
||||||
|
|
||||||
Long userId = loginUser.getUserId();
|
Long userId = loginUser.getUserId();
|
||||||
|
|
||||||
// 获取用户的角色集合
|
List<Long> roleIdList = null;
|
||||||
List<Long> roleIdList = sysUserRoleServiceApi.getUserRoleIdList(userId);
|
|
||||||
|
// 获取用户当前公司下的角色集合
|
||||||
|
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)) {
|
if (ObjectUtil.isEmpty(roleIdList)) {
|
||||||
userIndexInfo.setPermissionCodeList(new HashSet<>());
|
userIndexInfo.setPermissionCodeList(new HashSet<>());
|
||||||
|
|
Loading…
Reference in New Issue