fix: 角色可分配权限优化
This commit is contained in:
parent
b7d9a2036d
commit
f18a16ddb9
@ -22,13 +22,18 @@ public class SystemController {
|
||||
|
||||
@Operation(
|
||||
summary = "菜单 加载",
|
||||
description = "加载用户拥有的菜单",
|
||||
description = "加载用户拥有的菜单(用于显示在左侧)",
|
||||
tags = {"系统相关接口"}
|
||||
)
|
||||
@GetMapping("/menu")
|
||||
public ResponseEntity getMenu() {
|
||||
return ResponseEntity.ok(systemService.getMenu());
|
||||
}
|
||||
@Operation(
|
||||
summary = "菜单 加载 全部",
|
||||
description = "加载用户拥有的所有菜单,常常用于管理菜单",
|
||||
tags = {"系统相关接口"}
|
||||
)
|
||||
@GetMapping("/menu-all")
|
||||
public ResponseEntity getMenuAll() {
|
||||
return ResponseEntity.ok(systemService.getMenuAll());
|
||||
|
@ -2,6 +2,7 @@ package com.guaiguailang.harmony.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.guaiguailang.harmony.domain.entity.MenuDataItem;
|
||||
import com.guaiguailang.harmony.domain.entity.SystemRole;
|
||||
import com.guaiguailang.harmony.domain.entity.UserInfo;
|
||||
import com.guaiguailang.harmony.domain.vo.ResponseResult;
|
||||
import com.guaiguailang.harmony.mapper.SystemMapper;
|
||||
@ -37,7 +38,16 @@ public class SystemServiceImpl implements SystemService {
|
||||
|
||||
@Override
|
||||
public ResponseResult getMenuAll() {
|
||||
List<MenuDataItem> menus = systemMapper.getMenusAll();
|
||||
// 仅仅管理员放行,其他的只能加载自己有的
|
||||
SystemRole sr = userMapper.getRoleLevelByUserId(Long.parseLong(StpUtil.getLoginId().toString()));
|
||||
List<MenuDataItem> menus;
|
||||
if(sr.getLevel()==1){
|
||||
// 超级管理员,加载全部
|
||||
menus= systemMapper.getMenusAll();
|
||||
}else {
|
||||
menus = systemMapper.getMenus(sr.getRoleId());
|
||||
}
|
||||
|
||||
return ResponseResult.success(menus);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user