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
Eladmin
Commits
525c3567
Commit
525c3567
authored
Jun 20, 2019
by
zhengjie
Browse files
更换图形验证码工具,其他细节优化
parent
dca9929a
Changes
5
Hide whitespace changes
Inline
Side-by-side
eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthenticationController.java
View file @
525c3567
...
...
@@ -2,8 +2,6 @@ package me.zhengjie.modules.security.rest;
import
cn.hutool.core.codec.Base64
;
import
cn.hutool.core.util.IdUtil
;
import
com.wf.captcha.Captcha
;
import
com.wf.captcha.SpecCaptcha
;
import
lombok.extern.slf4j.Slf4j
;
import
me.zhengjie.aop.log.Log
;
import
me.zhengjie.exception.BadRequestException
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/MenuController.java
View file @
525c3567
...
...
@@ -81,6 +81,9 @@ public class MenuController {
@PutMapping
(
value
=
"/menus"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','MENU_ALL','MENU_EDIT')"
)
public
ResponseEntity
update
(
@Validated
(
Menu
.
Update
.
class
)
@RequestBody
Menu
resources
){
if
(
resources
.
getId
()
<=
new
Long
(
39
).
longValue
())
{
throw
new
BadRequestException
(
"演示环境不可操作"
);
}
menuService
.
update
(
resources
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
}
...
...
@@ -89,6 +92,9 @@ public class MenuController {
@DeleteMapping
(
value
=
"/menus/{id}"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','MENU_ALL','MENU_DELETE')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
if
(
id
.
longValue
()
<=
new
Long
(
39
).
longValue
())
{
throw
new
BadRequestException
(
"演示环境不可操作"
);
}
List
<
Menu
>
menuList
=
menuService
.
findByPid
(
id
);
// 特殊情况,对级联删除进行处理
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/PermissionController.java
View file @
525c3567
...
...
@@ -60,6 +60,9 @@ public class PermissionController {
@PutMapping
(
value
=
"/permissions"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','PERMISSION_ALL','PERMISSION_EDIT')"
)
public
ResponseEntity
update
(
@Validated
(
Permission
.
Update
.
class
)
@RequestBody
Permission
resources
){
if
(
resources
.
getId
()
<=
new
Long
(
54
).
longValue
())
{
throw
new
BadRequestException
(
"演示环境不可操作"
);
}
permissionService
.
update
(
resources
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
}
...
...
@@ -68,6 +71,9 @@ public class PermissionController {
@DeleteMapping
(
value
=
"/permissions/{id}"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','PERMISSION_ALL','PERMISSION_DELETE')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
if
(
id
<=
new
Long
(
54
).
longValue
())
{
throw
new
BadRequestException
(
"演示环境不可操作"
);
}
permissionService
.
delete
(
id
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
}
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/RoleController.java
View file @
525c3567
...
...
@@ -82,6 +82,9 @@ public class RoleController {
@PutMapping
(
value
=
"/roles"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','ROLES_ALL','ROLES_EDIT')"
)
public
ResponseEntity
update
(
@Validated
(
Role
.
Update
.
class
)
@RequestBody
Role
resources
){
if
(
resources
.
getId
().
equals
(
1L
))
{
throw
new
BadRequestException
(
"演示环境不可操作"
);
}
roleService
.
update
(
resources
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
}
...
...
@@ -90,6 +93,9 @@ public class RoleController {
@PutMapping
(
value
=
"/roles/permission"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','ROLES_ALL','ROLES_EDIT')"
)
public
ResponseEntity
updatePermission
(
@RequestBody
Role
resources
){
if
(
resources
.
getId
().
equals
(
1L
))
{
throw
new
BadRequestException
(
"演示环境不可操作"
);
}
roleService
.
updatePermission
(
resources
,
roleService
.
findById
(
resources
.
getId
()));
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
}
...
...
@@ -98,6 +104,9 @@ public class RoleController {
@PutMapping
(
value
=
"/roles/menu"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','ROLES_ALL','ROLES_EDIT')"
)
public
ResponseEntity
updateMenu
(
@RequestBody
Role
resources
){
if
(
resources
.
getId
().
equals
(
1L
))
{
throw
new
BadRequestException
(
"演示环境不可操作"
);
}
roleService
.
updateMenu
(
resources
,
roleService
.
findById
(
resources
.
getId
()));
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
}
...
...
@@ -106,6 +115,9 @@ public class RoleController {
@DeleteMapping
(
value
=
"/roles/{id}"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','ROLES_ALL','ROLES_DELETE')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
if
(
id
.
equals
(
1L
))
{
throw
new
BadRequestException
(
"演示环境不可操作"
);
}
roleService
.
delete
(
id
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
}
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java
View file @
525c3567
...
...
@@ -102,6 +102,9 @@ public class UserController {
@PutMapping
(
value
=
"/users"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','USER_ALL','USER_EDIT')"
)
public
ResponseEntity
update
(
@Validated
(
User
.
Update
.
class
)
@RequestBody
User
resources
){
if
(
resources
.
getId
().
equals
(
1L
))
{
throw
new
BadRequestException
(
"演示环境不可操作"
);
}
checkLevel
(
resources
);
userService
.
update
(
resources
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
...
...
@@ -111,6 +114,9 @@ public class UserController {
@DeleteMapping
(
value
=
"/users/{id}"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','USER_ALL','USER_DELETE')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
if
(
id
.
equals
(
1L
))
{
throw
new
BadRequestException
(
"演示环境不可操作"
);
}
Integer
currentLevel
=
Collections
.
min
(
roleService
.
findByUsers_Id
(
SecurityUtils
.
getUserId
()).
stream
().
map
(
RoleSmallDTO:
:
getLevel
).
collect
(
Collectors
.
toList
()));
Integer
optLevel
=
Collections
.
min
(
roleService
.
findByUsers_Id
(
id
).
stream
().
map
(
RoleSmallDTO:
:
getLevel
).
collect
(
Collectors
.
toList
()));
...
...
@@ -145,6 +151,9 @@ public class UserController {
@PostMapping
(
value
=
"/users/updatePass"
)
public
ResponseEntity
updatePass
(
@RequestBody
User
user
){
UserDetails
userDetails
=
SecurityUtils
.
getUserDetails
();
if
(
userDetails
.
getUsername
().
equals
(
"admin"
))
{
throw
new
BadRequestException
(
"演示环境不可操作"
);
}
if
(
userDetails
.
getPassword
().
equals
(
EncryptUtils
.
encryptPassword
(
user
.
getPassword
()))){
throw
new
BadRequestException
(
"新密码不能与旧密码相同"
);
}
...
...
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