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
5f43a5da
Commit
5f43a5da
authored
May 08, 2019
by
zhengjie
Browse files
修复用户多角色时登录失败的bug
parent
99041161
Changes
4
Hide whitespace changes
Inline
Side-by-side
eladmin-logging/src/main/java/me/zhengjie/aspect/
DataScope
Aspect.java
→
eladmin-logging/src/main/java/me/zhengjie/aspect/
Log
Aspect.java
View file @
5f43a5da
...
@@ -21,7 +21,7 @@ import org.springframework.stereotype.Component;
...
@@ -21,7 +21,7 @@ import org.springframework.stereotype.Component;
@Component
@Component
@Aspect
@Aspect
@Slf4j
@Slf4j
public
class
DataScope
Aspect
{
public
class
Log
Aspect
{
@Autowired
@Autowired
private
LogService
logService
;
private
LogService
logService
;
...
...
eladmin-system/src/main/java/me/zhengjie/config/ConfigurerAdapter.java
View file @
5f43a5da
...
@@ -35,7 +35,7 @@ public class ConfigurerAdapter implements WebMvcConfigurer {
...
@@ -35,7 +35,7 @@ public class ConfigurerAdapter implements WebMvcConfigurer {
}
}
// 可解决Long 类型在 前端精度丢失的问题, 如不想全局 直接添加注解 @JsonSerialize(using= ToStringSerializer.class) 到相应的字段
上
// 可解决Long 类型在 前端精度丢失的问题, 如不想全局 直接添加注解 @JsonSerialize(using= ToStringSerializer.class) 到相应的字段
// @Override
// @Override
// public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
// public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
...
...
eladmin-system/src/main/java/me/zhengjie/modules/security/service/JwtPermissionService.java
View file @
5f43a5da
package
me.zhengjie.modules.security.service
;
package
me.zhengjie.modules.security.service
;
import
me.zhengjie.modules.system.domain.Permission
;
import
me.zhengjie.modules.system.domain.Role
;
import
me.zhengjie.modules.system.domain.Role
;
import
me.zhengjie.modules.system.domain.User
;
import
me.zhengjie.modules.system.domain.User
;
import
me.zhengjie.modules.system.repository.PermissionRepository
;
import
me.zhengjie.modules.system.repository.RoleRepository
;
import
me.zhengjie.modules.system.repository.RoleRepository
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CacheConfig
;
...
@@ -12,7 +10,6 @@ import org.springframework.security.core.GrantedAuthority;
...
@@ -12,7 +10,6 @@ import org.springframework.security.core.GrantedAuthority;
import
org.springframework.security.core.authority.SimpleGrantedAuthority
;
import
org.springframework.security.core.authority.SimpleGrantedAuthority
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.HashSet
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -23,9 +20,6 @@ public class JwtPermissionService {
...
@@ -23,9 +20,6 @@ public class JwtPermissionService {
@Autowired
@Autowired
private
RoleRepository
roleRepository
;
private
RoleRepository
roleRepository
;
@Autowired
private
PermissionRepository
permissionRepository
;
@Cacheable
(
key
=
"'loadPermissionByUser:' + #p0.username"
)
@Cacheable
(
key
=
"'loadPermissionByUser:' + #p0.username"
)
public
Collection
<
GrantedAuthority
>
mapToGrantedAuthorities
(
User
user
)
{
public
Collection
<
GrantedAuthority
>
mapToGrantedAuthorities
(
User
user
)
{
...
@@ -33,11 +27,7 @@ public class JwtPermissionService {
...
@@ -33,11 +27,7 @@ public class JwtPermissionService {
Set
<
Role
>
roles
=
roleRepository
.
findByUsers_Id
(
user
.
getId
());
Set
<
Role
>
roles
=
roleRepository
.
findByUsers_Id
(
user
.
getId
());
Set
<
Permission
>
permissions
=
new
HashSet
<>();
return
roles
.
stream
().
flatMap
(
role
->
role
.
getPermissions
().
stream
())
permissions
.
addAll
(
permissionRepository
.
findByRoles
(
roles
));
return
permissions
.
stream
()
.
map
(
permission
->
new
SimpleGrantedAuthority
(
permission
.
getName
()))
.
map
(
permission
->
new
SimpleGrantedAuthority
(
permission
.
getName
()))
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
}
}
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/repository/PermissionRepository.java
View file @
5f43a5da
...
@@ -28,6 +28,4 @@ public interface PermissionRepository extends JpaRepository<Permission, Long>, J
...
@@ -28,6 +28,4 @@ public interface PermissionRepository extends JpaRepository<Permission, Long>, J
* @return
* @return
*/
*/
List
<
Permission
>
findByPid
(
long
pid
);
List
<
Permission
>
findByPid
(
long
pid
);
Set
<
Permission
>
findByRoles
(
Set
<
Role
>
roles
);
}
}
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