mirror of https://gitee.com/stylefeng/roses
【7.6.0】【sys】不能修改默认管理员的账号和超级管理员标识
parent
c9a43ff7b0
commit
37db3c5c7c
|
@ -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";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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的超级管理员标识");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 错误编码
|
* 错误编码
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
// 编辑不能修改密码
|
// 编辑不能修改密码
|
||||||
|
|
Loading…
Reference in New Issue