diff --git a/src/main/java/com/guaiguailang/harmony/controller/SystemController.java b/src/main/java/com/guaiguailang/harmony/controller/SystemController.java index a8567a1..89534a6 100644 --- a/src/main/java/com/guaiguailang/harmony/controller/SystemController.java +++ b/src/main/java/com/guaiguailang/harmony/controller/SystemController.java @@ -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()); diff --git a/src/main/java/com/guaiguailang/harmony/service/impl/SystemServiceImpl.java b/src/main/java/com/guaiguailang/harmony/service/impl/SystemServiceImpl.java index 4f96706..33bf8d2 100644 --- a/src/main/java/com/guaiguailang/harmony/service/impl/SystemServiceImpl.java +++ b/src/main/java/com/guaiguailang/harmony/service/impl/SystemServiceImpl.java @@ -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 menus = systemMapper.getMenusAll(); + // 仅仅管理员放行,其他的只能加载自己有的 + SystemRole sr = userMapper.getRoleLevelByUserId(Long.parseLong(StpUtil.getLoginId().toString())); + List menus; + if(sr.getLevel()==1){ + // 超级管理员,加载全部 + menus= systemMapper.getMenusAll(); + }else { + menus = systemMapper.getMenus(sr.getRoleId()); + } + return ResponseResult.success(menus); }