问题修复:允许用户修改自身信息,但是不允许修改自身状态为禁用

This commit is contained in:
gaoqr
2024-08-28 12:10:39 +08:00
parent 619b14bc00
commit ca75a49cfe
2 changed files with 13 additions and 4 deletions
@@ -71,6 +71,7 @@ import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.e
import static com.cf.imes.framework.common.util.collection.CollectionUtils.convertList;
import static com.cf.imes.framework.common.util.collection.CollectionUtils.convertSet;
import static com.cf.imes.module.system.enums.ErrorCodeConstants.USER_ME_ERROR;
import static com.cf.imes.module.system.enums.ErrorCodeConstants.USER_OPERATE_SELF_STATUS_ERROR;
/**
* 后台用户 Service 实现类
@@ -156,8 +157,8 @@ public class AdminUserServiceImpl implements AdminUserService {
@Transactional(rollbackFor = Exception.class)
public void updateUser(UserSaveReqVO updateReqVO) {
Long organId = updateReqVO.getOrganId() == null ? OrganContextHolder.getOrganId(): updateReqVO.getOrganId();
// 不允许自身操作
checkCurrentWhenOperate(updateReqVO.getId());
// 不允许关闭自身状态
checkCurrentWhenOperateStatus(updateReqVO.getId(), updateReqVO.getStatus());
// 校验正确性
validateUserForCreateOrUpdate(updateReqVO.getId(), updateReqVO.getUsername(),
updateReqVO.getEmail(), updateReqVO.getDeptId(), updateReqVO.getPostIds(), null, organId);
@@ -673,6 +674,12 @@ public class AdminUserServiceImpl implements AdminUserService {
}
}
private void checkCurrentWhenOperateStatus(Long userId, Integer status) {
if (ObjectUtil.equal(userId, SecurityFrameworkUtils.getLoginUserId()) && Objects.equals(CommonStatusEnum.DISABLE.getStatus(), status)) {
throw exception(USER_OPERATE_SELF_STATUS_ERROR);
}
}
@Override
public Map<String, Integer> userTotal() {
Map<String, Integer> map = new HashMap<>();