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
207e6fb1
Commit
207e6fb1
authored
Mar 10, 2020
by
Elune
Browse files
SecurityUtils 加入获取当前登录用户ID方法,Security 结构调整
parent
4054ac7b
Changes
25
Hide whitespace changes
Inline
Side-by-side
eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/UserDto.java
View file @
207e6fb1
...
...
@@ -3,9 +3,12 @@ package me.zhengjie.modules.system.service.dto;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
org.springframework.security.core.GrantedAuthority
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Set
;
/**
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/RoleServiceImpl.java
View file @
207e6fb1
...
...
@@ -153,7 +153,7 @@ public class RoleServiceImpl implements RoleService {
@Override
@Cacheable
(
key
=
"'loadPermissionByUser:' + #p0.username"
)
public
Collection
<
GrantedAuthority
>
mapToGrantedAuthorities
(
UserDto
user
)
{
public
List
<
GrantedAuthority
>
mapToGrantedAuthorities
(
UserDto
user
)
{
Set
<
Role
>
roles
=
roleRepository
.
findByUsers_Id
(
user
.
getId
());
Set
<
String
>
permissions
=
roles
.
stream
().
filter
(
role
->
StringUtils
.
isNotBlank
(
role
.
getPermission
())).
map
(
Role:
:
getPermission
).
collect
(
Collectors
.
toSet
());
permissions
.
addAll
(
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java
View file @
207e6fb1
...
...
@@ -171,7 +171,7 @@ public class UserServiceImpl implements UserService {
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateAvatar
(
MultipartFile
multipartFile
)
{
User
user
=
userRepository
.
findByUsername
(
SecurityUtils
.
getUsername
());
User
user
=
userRepository
.
findByUsername
(
SecurityUtils
.
get
Current
Username
());
UserAvatar
userAvatar
=
user
.
getUserAvatar
();
String
oldPath
=
""
;
if
(
userAvatar
!=
null
){
...
...
eladmin-tools/src/main/java/me/zhengjie/rest/PictureController.java
View file @
207e6fb1
...
...
@@ -52,7 +52,7 @@ public class PictureController {
@PostMapping
@ApiOperation
(
"上传图片"
)
public
ResponseEntity
<
Object
>
upload
(
@RequestParam
MultipartFile
file
){
String
userName
=
SecurityUtils
.
getUsername
();
String
userName
=
SecurityUtils
.
get
Current
Username
();
Picture
picture
=
pictureService
.
upload
(
file
,
userName
);
return
new
ResponseEntity
<>(
picture
,
HttpStatus
.
OK
);
}
...
...
eladmin-tools/src/main/java/me/zhengjie/service/impl/LocalStorageServiceImpl.java
View file @
207e6fb1
...
...
@@ -94,7 +94,7 @@ public class LocalStorageServiceImpl implements LocalStorageService {
file
.
getPath
(),
type
,
FileUtil
.
getSize
(
multipartFile
.
getSize
()),
SecurityUtils
.
getUsername
()
SecurityUtils
.
get
Current
Username
()
);
return
localStorageMapper
.
toDto
(
localStorageRepository
.
save
(
localStorage
));
}
catch
(
Exception
e
){
...
...
Prev
1
2
Next
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