【7.0.2】超级管理员角色编码不能修改

pull/12/head
fengshuonan 2021-03-20 11:40:05 +08:00
parent 681d90e5b5
commit ebcf892adf
2 changed files with 16 additions and 1 deletions

View File

@ -42,7 +42,12 @@ public enum SysRoleExceptionEnum implements AbstractExceptionEnum {
/**
*
*/
PLEASE_FILL_DATA_SCOPE(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + SystemConstants.SYSTEM_EXCEPTION_STEP_CODE + "66", "指定部门类型的数据范围必须选择组织机构");
PLEASE_FILL_DATA_SCOPE(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + SystemConstants.SYSTEM_EXCEPTION_STEP_CODE + "66", "指定部门类型的数据范围必须选择组织机构"),
/**
*
*/
SUPER_ADMIN_ROLE_CODE_ERROR(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + SystemConstants.SYSTEM_EXCEPTION_STEP_CODE + "67", "超级管理员角色编码不能被修改");
/**
*

View File

@ -17,6 +17,7 @@ import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict;
import cn.stylefeng.roses.kernel.system.api.UserServiceApi;
import cn.stylefeng.roses.kernel.system.api.constants.SystemConstants;
import cn.stylefeng.roses.kernel.system.api.exception.SystemModularException;
import cn.stylefeng.roses.kernel.system.api.exception.enums.role.SysRoleExceptionEnum;
import cn.stylefeng.roses.kernel.system.modular.role.entity.*;
@ -114,6 +115,15 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
@Override
public void edit(SysRoleRequest sysRoleRequest) {
SysRole sysRole = this.querySysRole(sysRoleRequest);
// 不能修改超级管理员编码
if (SystemConstants.SUPER_ADMIN_ROLE_CODE.equals(sysRole.getRoleCode())) {
if (!sysRole.getRoleCode().equals(sysRoleRequest.getRoleCode())) {
throw new SystemModularException(SysRoleExceptionEnum.SUPER_ADMIN_ROLE_CODE_ERROR);
}
}
// 拷贝属性
BeanUtil.copyProperties(sysRoleRequest, sysRole);
// 不能修改状态,用修改状态接口修改状态