Commit 67959f6c by fsn

新增不能删除超级管理员用户和角色

parent 4f5f21c1
......@@ -18,4 +18,14 @@ public interface Const {
*/
String ADMIN_NAME = "administrator";
/**
* 管理员id
*/
Integer ADMIN_ID = 1;
/**
* 超级管理员角色id
*/
Integer ADMIN_ROLE_ID = 1;
}
......@@ -29,6 +29,9 @@ public enum BizExceptionEnum {
NO_PERMITION(405, "权限异常"),
REQUEST_INVALIDATE(400,"请求数据格式不正确"),
INVALID_KAPTCHA(400,"验证码不正确"),
CANT_DELETE_ADMIN(600,"不能删除超级管理员"),
CANT_FREEZE_ADMIN(600,"不能冻结超级管理员"),
CANT_CHANGE_ADMIN(600,"不能修改超级管理员角色"),
/**
* 账户问题
......
......@@ -160,6 +160,11 @@ public class RoleController extends BaseController {
throw new BussinessException(BizExceptionEnum.REQUEST_NULL);
}
//不能删除超级管理员角色
if(roleId.equals(Const.ADMIN_ROLE_ID)){
throw new BussinessException(BizExceptionEnum.CANT_DELETE_ADMIN);
}
//缓存被删除的角色名称
LogObjectHolder.me().set(ConstantFactory.me().getSingleRoleName(roleId));
......
......@@ -225,6 +225,10 @@ public class UserMgrController extends BaseController {
if (ToolUtil.isEmpty(userId)) {
throw new BussinessException(BizExceptionEnum.REQUEST_NULL);
}
//不能删除超级管理员
if(userId.equals(Const.ADMIN_ID)){
throw new BussinessException(BizExceptionEnum.CANT_DELETE_ADMIN);
}
this.managerDao.setStatus(userId, ManagerStatus.DELETED.getCode());
return SUCCESS_TIP;
}
......@@ -270,6 +274,10 @@ public class UserMgrController extends BaseController {
if (ToolUtil.isEmpty(userId)) {
throw new BussinessException(BizExceptionEnum.REQUEST_NULL);
}
//不能冻结超级管理员
if(userId.equals(Const.ADMIN_ID)){
throw new BussinessException(BizExceptionEnum.CANT_FREEZE_ADMIN);
}
this.managerDao.setStatus(userId, ManagerStatus.FREEZED.getCode());
return SUCCESS_TIP;
}
......@@ -300,6 +308,10 @@ public class UserMgrController extends BaseController {
if (ToolUtil.isOneEmpty(userId, roleIds)) {
throw new BussinessException(BizExceptionEnum.REQUEST_NULL);
}
//不能修改超级管理员
if(userId.equals(Const.ADMIN_ID)){
throw new BussinessException(BizExceptionEnum.CANT_CHANGE_ADMIN);
}
this.managerDao.setRoles(userId, roleIds);
return SUCCESS_TIP;
}
......
......@@ -73,7 +73,7 @@ ${context.bizEnBigName}.delete = function () {
Feng.success("删除成功!");
${context.bizEnBigName}.table.refresh();
}, function (data) {
Feng.error("删除失败!");
Feng.error("删除失败!" + data.responseJSON.message + "!");
});
ajax.set("${context.bizEnName}Id",this.seItem.id);
ajax.start();
......
......@@ -77,7 +77,7 @@ Dept.delete = function () {
Feng.success("删除成功!");
Dept.table.refresh();
}, function (data) {
Feng.error("删除失败!");
Feng.error("删除失败!" + data.responseJSON.message + "!");
});
ajax.set("deptId",this.seItem.id);
ajax.start();
......
......@@ -75,7 +75,7 @@ Dict.delete = function () {
Feng.success("删除成功!");
Dict.table.refresh();
}, function (data) {
Feng.error("删除失败!");
Feng.error("删除失败!" + data.responseJSON.message + "!");
});
ajax.set("dictId", this.seItem.id);
ajax.start();
......
......@@ -81,7 +81,7 @@ Menu.delMenu = function () {
Feng.success("删除成功!");
Menu.table.refresh();
}, function (data) {
Feng.error("删除失败!");
Feng.error("删除失败!" + data.responseJSON.message + "!");
});
ajax.set("menuId", this.seItem.id);
ajax.start();
......
......@@ -77,7 +77,7 @@ Notice.delete = function () {
Feng.success("删除成功!");
Notice.table.refresh();
}, function (data) {
Feng.error("删除失败!");
Feng.error("删除失败!" + data.responseJSON.message + "!");
});
ajax.set("noticeId", this.seItem.id);
ajax.start();
......
......@@ -78,7 +78,7 @@ Role.delRole = function () {
Feng.success("删除成功!");
Role.table.refresh();
}, function (data) {
Feng.error("删除失败!");
Feng.error("删除失败!" + data.responseJSON.message + "!");
});
ajax.set("roleId", this.seItem.id);
ajax.start();
......
......@@ -102,7 +102,7 @@ MgrUser.delMgrUser = function () {
Feng.success("删除成功!");
MgrUser.table.refresh();
}, function (data) {
Feng.error("删除失败!");
Feng.error("删除失败!" + data.responseJSON.message + "!");
});
ajax.set("userId", userId);
ajax.start();
......@@ -120,7 +120,7 @@ MgrUser.freezeAccount = function () {
Feng.success("冻结成功!");
MgrUser.table.refresh();
}, function (data) {
Feng.error("冻结失败!");
Feng.error("冻结失败!" + data.responseJSON.message + "!");
});
ajax.set("userId", userId);
ajax.start();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment