Merge remote-tracking branch 'origin/main'

This commit is contained in:
liuzhaotian
2024-06-26 14:56:28 +08:00
3 changed files with 35 additions and 32 deletions
@@ -172,8 +172,9 @@ public class PermissionServiceImpl implements PermissionService {
throw new ServiceException(ErrorCodeConstants.ROLE_NOT_EXISTS);
}
// 前端没传或者查一次后切换了组织导致跟角色组织不一致的统一为角色的组织
if (Objects.isNull(organId) || ObjectUtil.notEqual(role.getOrganId(), organId)) {
organId = role.getOrganId();
Long roleOrganId = role.getOrganId();
if (Objects.isNull(organId) || ObjectUtil.notEqual(roleOrganId, organId)) {
organId = roleOrganId;
}
final Long finalOrganId = organId;
@@ -304,6 +305,8 @@ public class PermissionServiceImpl implements PermissionService {
Set<Long> userIds = reqVO.getUserIds();
// 组织id
Long organId = reqVO.getOrganId();
// 角色id
Long roleId = reqVO.getRoleId();
// 超管不传组织id则操作本机构角色
// 非超管不传组织id不允许操作
if (isSupAdmin) {
@@ -313,8 +316,18 @@ public class PermissionServiceImpl implements PermissionService {
throw new ServiceException(ErrorCodeConstants.ROLE_NOT_SUPERADMIN_NO_ORGAN_ID_OPER_ERROR);
}
}
// 查询角色获取角色的组织id,如果没有传入组织id就跟角色的组织统一
RoleDO role = roleService.getRole(roleId);
if (Objects.isNull(role)) {
throw new ServiceException(ErrorCodeConstants.ROLE_NOT_EXISTS);
}
// 前端没传或者查一次后切换了组织导致跟角色组织不一致的统一为角色的组织
Long roleOrganId = role.getOrganId();
if (Objects.isNull(organId) || ObjectUtil.notEqual(roleOrganId, organId)) {
organId = roleOrganId;
}
final Long finalOrganId = organId;
Long roleId = reqVO.getRoleId();
// 当前用户不能操作含有自己的角色
if (CollectionUtil.isNotEmpty(userIds)) {
Long incloudSelf = userIds.stream().filter(userId -> userId.equals(loginUser.getId())).findAny().orElse(null);