From f18a16ddb991d977ca9ed353f458974c589179d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=8C=E7=8B=BC=E8=93=9D=E5=A4=A9?= Date: Thu, 7 Nov 2024 17:08:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=92=E8=89=B2=E5=8F=AF=E5=88=86?= =?UTF-8?q?=E9=85=8D=E6=9D=83=E9=99=90=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../harmony/controller/SystemController.java | 7 ++++++- .../harmony/service/impl/SystemServiceImpl.java | 12 +++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) 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); }