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
59bf09eb
Commit
59bf09eb
authored
May 19, 2020
by
ZhengJie
Browse files
[代码完善](v2.5): v2.5 beta 代码优化,修复role::auth缓存问题,修复角色菜单问题
close #358
parent
1af4eb89
Changes
2
Hide whitespace changes
Inline
Side-by-side
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/MenuController.java
View file @
59bf09eb
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
*/
*/
package
me.zhengjie.modules.system.rest
;
package
me.zhengjie.modules.system.rest
;
import
cn.hutool.core.collection.CollectionUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
...
@@ -86,13 +87,16 @@ public class MenuController {
...
@@ -86,13 +87,16 @@ public class MenuController {
@ApiOperation
(
"查询菜单:根据ID获取同级与上级数据"
)
@ApiOperation
(
"查询菜单:根据ID获取同级与上级数据"
)
@GetMapping
(
"/superior"
)
@GetMapping
(
"/superior"
)
@PreAuthorize
(
"@el.check('menu:list')"
)
@PreAuthorize
(
"@el.check('menu:list')"
)
public
ResponseEntity
<
Object
>
getSuperior
(
@RequestParam
List
<
Long
>
ids
)
{
public
ResponseEntity
<
Object
>
getSuperior
(
@RequestParam
(
required
=
false
)
List
<
Long
>
ids
)
{
Set
<
MenuDto
>
menuDtos
=
new
LinkedHashSet
<>();
Set
<
MenuDto
>
menuDtos
=
new
LinkedHashSet
<>();
for
(
Long
id
:
ids
)
{
if
(
CollectionUtil
.
isNotEmpty
(
ids
)){
MenuDto
menuDto
=
menuService
.
findById
(
id
);
for
(
Long
id
:
ids
)
{
menuDtos
.
addAll
(
menuService
.
getSuperior
(
menuDto
,
new
ArrayList
<>()));
MenuDto
menuDto
=
menuService
.
findById
(
id
);
menuDtos
.
addAll
(
menuService
.
getSuperior
(
menuDto
,
new
ArrayList
<>()));
}
return
new
ResponseEntity
<>(
menuService
.
buildTree
(
new
ArrayList
<>(
menuDtos
)),
HttpStatus
.
OK
);
}
}
return
new
ResponseEntity
<>(
menuService
.
buildTree
(
new
ArrayList
<>(
menuDtos
)
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
menuService
.
getMenus
(
null
),
HttpStatus
.
OK
);
}
}
@Log
(
"新增菜单"
)
@Log
(
"新增菜单"
)
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/RoleServiceImpl.java
View file @
59bf09eb
...
@@ -164,7 +164,7 @@ public class RoleServiceImpl implements RoleService {
...
@@ -164,7 +164,7 @@ public class RoleServiceImpl implements RoleService {
}
}
@Override
@Override
@Cacheable
(
key
=
"'auth:' + #p0"
)
@Cacheable
(
key
=
"'auth:' + #p0
.id
"
)
public
List
<
GrantedAuthority
>
mapToGrantedAuthorities
(
UserDto
user
)
{
public
List
<
GrantedAuthority
>
mapToGrantedAuthorities
(
UserDto
user
)
{
Set
<
String
>
permissions
=
new
HashSet
<>();
Set
<
String
>
permissions
=
new
HashSet
<>();
// 如果是管理员直接返回
// 如果是管理员直接返回
...
...
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