mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
问题修复:允许用户修改自身信息,但是不允许修改自身状态为禁用
This commit is contained in:
+4
-2
@@ -45,8 +45,7 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode USER_PASSWORD_FAILED = new ErrorCode(1_002_003_005, "用户密码校验失败");
|
||||
ErrorCode USER_IS_DISABLE = new ErrorCode(1_002_003_006, "名字为【{}】的用户已被禁用");
|
||||
ErrorCode USER_COUNT_MAX = new ErrorCode(1_002_003_008, "创建用户失败,原因:超过组织最大组织配额({})!");
|
||||
ErrorCode USER_ME_ERROR = new ErrorCode(1_002_003_009, "不可操作用户自身");
|
||||
ErrorCode USERNAME_MULTIPLE_ERROR = new ErrorCode(1_002_003_010,"存在【{}】重复用户,请联系系统管理员");
|
||||
ErrorCode USER_ME_ERROR = new ErrorCode(1_002_003_009, "不允许操作用户自身");
|
||||
|
||||
ErrorCode THE_PASSWORD_LENGTH_MUST_BE_AT_LEAST_6_CHARACTERS = new ErrorCode(1_002_003_010, "密码长度必须至少为6个字符");
|
||||
|
||||
@@ -56,6 +55,9 @@ public interface ErrorCodeConstants {
|
||||
|
||||
ErrorCode PASSWORDS_CAN_ONLY_CONTAIN_LETTERS_AND_NUMBERS = new ErrorCode(1_002_003_013, "密码只能包含字母和数字");
|
||||
ErrorCode INSUFFICIENT_PERMISSIONS = new ErrorCode(1_002_003_014, "当前用户权限不足,无法修改开料状态");
|
||||
ErrorCode USERNAME_MULTIPLE_ERROR = new ErrorCode(1_002_003_015,"存在【{}】重复用户,请联系系统管理员");
|
||||
ErrorCode USER_OPERATE_SELF_STATUS_ERROR = new ErrorCode(1_002_003_016, "不允许操作用户自身状态");
|
||||
|
||||
|
||||
// ========== 部门模块 1-002-004-000 ==========
|
||||
ErrorCode DEPT_NAME_DUPLICATE = new ErrorCode(1_002_004_000, "已经存在该名字的部门");
|
||||
|
||||
+9
-2
@@ -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<>();
|
||||
|
||||
Reference in New Issue
Block a user