[代码完善](v2.5): v2.5 beta 代码优化,修复role::auth缓存问题,修复角色菜单问题

close #358
pull/372/head
ZhengJie 2020-05-19 12:39:03 +08:00
parent 1af4eb89d2
commit 59bf09eb31
2 changed files with 10 additions and 6 deletions

View File

@ -15,6 +15,7 @@
*/
package me.zhengjie.modules.system.rest;
import cn.hutool.core.collection.CollectionUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
@ -86,14 +87,17 @@ public class MenuController {
@ApiOperation("查询菜单:根据ID获取同级与上级数据")
@GetMapping("/superior")
@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<>();
if(CollectionUtil.isNotEmpty(ids)){
for (Long id : ids) {
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.getMenus(null),HttpStatus.OK);
}
@Log("新增菜单")
@ApiOperation("新增菜单")

View File

@ -164,7 +164,7 @@ public class RoleServiceImpl implements RoleService {
}
@Override
@Cacheable(key = "'auth:' + #p0")
@Cacheable(key = "'auth:' + #p0.id")
public List<GrantedAuthority> mapToGrantedAuthorities(UserDto user) {
Set<String> permissions = new HashSet<>();
// 如果是管理员直接返回