【7.6.0】【sys】不能修改默认管理员的账号和超级管理员标识

pull/57/head
fengshuonan 2023-06-28 15:51:29 +08:00
parent c9a43ff7b0
commit 37db3c5c7c
3 changed files with 29 additions and 1 deletions

View File

@ -62,4 +62,9 @@ public interface SysConstants {
*/ */
Integer SUPER_ADMIN_INIT_LISTENER_SORT = 400; Integer SUPER_ADMIN_INIT_LISTENER_SORT = 400;
/**
*
*/
String ADMIN_USER_ACCOUNT = "admin";
} }

View File

@ -48,7 +48,17 @@ public enum SysUserExceptionEnum implements AbstractExceptionEnum {
/** /**
* *
*/ */
CANT_CHANGE_ADMIN_ROLE(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10007", "不能修改超级管理员的角色"); CANT_CHANGE_ADMIN_ROLE(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10007", "不能修改超级管理员的角色"),
/**
* admin
*/
CANT_CHANGE_ADMIN_ACCOUNT(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10008", "不能修改管理员admin的账号"),
/**
* admin
*/
CANT_CHANGE_ADMIN_FLAG(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10009", "不能修改管理员admin的超级管理员标识");
/** /**
* *

View File

@ -17,6 +17,7 @@ import cn.stylefeng.roses.kernel.file.api.constants.FileConstants;
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum; import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException; import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
import cn.stylefeng.roses.kernel.sys.api.callback.RemoveUserCallbackApi; import cn.stylefeng.roses.kernel.sys.api.callback.RemoveUserCallbackApi;
import cn.stylefeng.roses.kernel.sys.api.constants.SysConstants;
import cn.stylefeng.roses.kernel.sys.api.enums.user.UserStatusEnum; import cn.stylefeng.roses.kernel.sys.api.enums.user.UserStatusEnum;
import cn.stylefeng.roses.kernel.sys.api.exception.enums.UserExceptionEnum; import cn.stylefeng.roses.kernel.sys.api.exception.enums.UserExceptionEnum;
import cn.stylefeng.roses.kernel.sys.api.expander.SysConfigExpander; import cn.stylefeng.roses.kernel.sys.api.expander.SysConfigExpander;
@ -125,6 +126,18 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
@Override @Override
public void edit(SysUserRequest sysUserRequest) { public void edit(SysUserRequest sysUserRequest) {
SysUser sysUser = this.querySysUser(sysUserRequest); SysUser sysUser = this.querySysUser(sysUserRequest);
// 不能修改admin账号的超级管理员标识和账号
if (SysConstants.ADMIN_USER_ACCOUNT.equals(sysUser.getAccount())) {
if (!sysUser.getAccount().equals(sysUserRequest.getAccount())) {
throw new ServiceException(SysUserExceptionEnum.CANT_CHANGE_ADMIN_ACCOUNT);
}
if (YesOrNotEnum.N.getCode().equals(sysUserRequest.getSuperAdminFlag())) {
throw new ServiceException(SysUserExceptionEnum.CANT_CHANGE_ADMIN_FLAG);
}
}
// copy属性
BeanUtil.copyProperties(sysUserRequest, sysUser); BeanUtil.copyProperties(sysUserRequest, sysUser);
// 编辑不能修改密码 // 编辑不能修改密码