Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
guns-vip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjunxiong
guns-vip
Commits
67959f6c
Commit
67959f6c
authored
May 27, 2017
by
fsn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增不能删除超级管理员用户和角色
parent
4f5f21c1
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
38 additions
and
8 deletions
+38
-8
src/main/java/com/stylefeng/guns/common/constant/Const.java
+10
-0
src/main/java/com/stylefeng/guns/common/exception/BizExceptionEnum.java
+3
-0
src/main/java/com/stylefeng/guns/modular/system/controller/RoleController.java
+5
-0
src/main/java/com/stylefeng/guns/modular/system/controller/UserMgrController.java
+12
-0
src/main/resources/gunsTemplate/page.js.btl
+1
-1
src/main/webapp/static/modular/system/dept/dept.js
+1
-1
src/main/webapp/static/modular/system/dict/dict.js
+1
-1
src/main/webapp/static/modular/system/menu/menu.js
+1
-1
src/main/webapp/static/modular/system/notice/notice.js
+1
-1
src/main/webapp/static/modular/system/role/role.js
+1
-1
src/main/webapp/static/modular/system/user/user.js
+2
-2
No files found.
src/main/java/com/stylefeng/guns/common/constant/Const.java
View file @
67959f6c
...
...
@@ -18,4 +18,14 @@ public interface Const {
*/
String
ADMIN_NAME
=
"administrator"
;
/**
* 管理员id
*/
Integer
ADMIN_ID
=
1
;
/**
* 超级管理员角色id
*/
Integer
ADMIN_ROLE_ID
=
1
;
}
src/main/java/com/stylefeng/guns/common/exception/BizExceptionEnum.java
View file @
67959f6c
...
...
@@ -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
,
"不能修改超级管理员角色"
),
/**
* 账户问题
...
...
src/main/java/com/stylefeng/guns/modular/system/controller/RoleController.java
View file @
67959f6c
...
...
@@ -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
));
...
...
src/main/java/com/stylefeng/guns/modular/system/controller/UserMgrController.java
View file @
67959f6c
...
...
@@ -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
;
}
...
...
src/main/resources/gunsTemplate/page.js.btl
View file @
67959f6c
...
...
@@ -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();
...
...
src/main/webapp/static/modular/system/dept/dept.js
View file @
67959f6c
...
...
@@ -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
();
...
...
src/main/webapp/static/modular/system/dict/dict.js
View file @
67959f6c
...
...
@@ -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
();
...
...
src/main/webapp/static/modular/system/menu/menu.js
View file @
67959f6c
...
...
@@ -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
();
...
...
src/main/webapp/static/modular/system/notice/notice.js
View file @
67959f6c
...
...
@@ -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
();
...
...
src/main/webapp/static/modular/system/role/role.js
View file @
67959f6c
...
...
@@ -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
();
...
...
src/main/webapp/static/modular/system/user/user.js
View file @
67959f6c
...
...
@@ -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
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment