Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
04bf86cb
Commit
04bf86cb
authored
Aug 02, 2018
by
Junling Bu
Browse files
fix[litemall-admin-api]: 添加管理员账户进行进行校验。
parent
f6923f3f
Changes
1
Hide whitespace changes
Inline
Side-by-side
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminAdminController.java
View file @
04bf86cb
...
@@ -9,6 +9,7 @@ import org.linlinjava.litemall.core.validator.Sort;
...
@@ -9,6 +9,7 @@ import org.linlinjava.litemall.core.validator.Sort;
import
org.linlinjava.litemall.db.domain.LitemallAdmin
;
import
org.linlinjava.litemall.db.domain.LitemallAdmin
;
import
org.linlinjava.litemall.db.service.LitemallAdminService
;
import
org.linlinjava.litemall.db.service.LitemallAdminService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.Assert
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
@@ -75,7 +76,19 @@ public class AdminAdminController {
...
@@ -75,7 +76,19 @@ public class AdminAdminController {
return
ResponseUtil
.
unlogin
();
return
ResponseUtil
.
unlogin
();
}
}
String
username
=
admin
.
getUsername
();
if
(
username
==
null
){
return
ResponseUtil
.
badArgument
();
}
List
<
LitemallAdmin
>
adminList
=
adminService
.
findAdmin
(
username
);
if
(
adminList
.
size
()
>
0
){
return
ResponseUtil
.
fail
(
402
,
"管理员已经存在"
);
}
String
rawPassword
=
admin
.
getPassword
();
String
rawPassword
=
admin
.
getPassword
();
if
(
rawPassword
==
null
||
rawPassword
.
length
()
<
6
){
return
ResponseUtil
.
fail
(
402
,
"管理员密码长度不能小于6"
);
}
BCryptPasswordEncoder
encoder
=
new
BCryptPasswordEncoder
();
BCryptPasswordEncoder
encoder
=
new
BCryptPasswordEncoder
();
String
encodedPassword
=
encoder
.
encode
(
rawPassword
);
String
encodedPassword
=
encoder
.
encode
(
rawPassword
);
admin
.
setPassword
(
encodedPassword
);
admin
.
setPassword
(
encodedPassword
);
...
@@ -102,7 +115,7 @@ public class AdminAdminController {
...
@@ -102,7 +115,7 @@ public class AdminAdminController {
}
}
Integer
anotherAdminId
=
admin
.
getId
();
Integer
anotherAdminId
=
admin
.
getId
();
if
(
anotherAdminId
.
intValue
()
==
1
){
if
(
anotherAdminId
==
1
){
return
ResponseUtil
.
fail
(
403
,
"超级管理员不能修改"
);
return
ResponseUtil
.
fail
(
403
,
"超级管理员不能修改"
);
}
}
...
@@ -122,7 +135,7 @@ public class AdminAdminController {
...
@@ -122,7 +135,7 @@ public class AdminAdminController {
}
}
Integer
anotherAdminId
=
admin
.
getId
();
Integer
anotherAdminId
=
admin
.
getId
();
if
(
anotherAdminId
.
intValue
()
==
1
){
if
(
anotherAdminId
==
1
){
return
ResponseUtil
.
fail
(
403
,
"超级管理员不能删除"
);
return
ResponseUtil
.
fail
(
403
,
"超级管理员不能删除"
);
}
}
adminService
.
deleteById
(
anotherAdminId
);
adminService
.
deleteById
(
anotherAdminId
);
...
...
Write
Preview
Supports
Markdown
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