mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
权限问题修复:内置角色分配用户的userole指向所选机构
This commit is contained in:
+8
-9
@@ -346,19 +346,13 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
}
|
||||
// 前端没传或者查一次后切换了组织导致跟角色组织不一致的统一为角色的组织
|
||||
Long roleOrganId = role.getOrganId();
|
||||
if (Objects.isNull(organId) || ObjectUtil.notEqual(roleOrganId, organId)) {
|
||||
boolean isOrganRole = Objects.equals(roleId, InternalRoleConstants.ORGAN_ADMIN_ROLE_ID) || Objects.equals(roleId, InternalRoleConstants.ORGAN_STAFF_ROLE_ID);
|
||||
// 内置角色还是按照机构来存
|
||||
if (!isOrganRole && (Objects.isNull(organId) || ObjectUtil.notEqual(roleOrganId, organId))) {
|
||||
organId = roleOrganId;
|
||||
}
|
||||
final Long finalOrganId = organId;
|
||||
|
||||
// 当前用户不能操作含有自己的角色
|
||||
if (CollectionUtil.isNotEmpty(userIds)) {
|
||||
Long incloudSelf = userIds.stream().filter(userId -> userId.equals(loginUser.getId())).findAny().orElse(null);
|
||||
if (incloudSelf != null) {
|
||||
throw new ServiceException(ROLE_ME_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
// 获得角色下的角色用户列表
|
||||
Set<Long> roleUserIds = convertSet(userRoleMapper.selectList(new LambdaQueryWrapperX<UserRoleDO>()
|
||||
.eqIfPresent(UserRoleDO::getOrganId, organId)
|
||||
@@ -378,6 +372,11 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
// 筛选要删除的userRole:前端没有,数据库有
|
||||
Collection<Long> deleteRoleUserIds = CollUtil.subtract(roleUserIds, userIds);
|
||||
if (!CollectionUtil.isEmpty(deleteRoleUserIds)) {
|
||||
// 当前用户不能移除自身的角色
|
||||
Long incloudSelf = deleteRoleUserIds.stream().filter(userId -> userId.equals(loginUser.getId())).findAny().orElse(null);
|
||||
if (incloudSelf != null) {
|
||||
throw new ServiceException(ROLE_ME_ERROR);
|
||||
}
|
||||
userRoleMapper.deleteListByRoleIdAndUserIds(roleId, deleteRoleUserIds);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user