From 43a96897ce6c95b7871f95d53d80b5053e7f02cf Mon Sep 17 00:00:00 2001 From: WendyYang Date: Fri, 31 Mar 2023 16:42:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=99=BB=E5=BD=95=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E8=A7=92=E8=89=B2=E6=9F=A5=E8=AF=A2=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ningdatech/pmapi/sys/controller/MenuController.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/MenuController.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/MenuController.java index d141dc4..e6d5251 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/MenuController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/MenuController.java @@ -1,6 +1,7 @@ package com.ningdatech.pmapi.sys.controller; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ningdatech.basic.util.CollUtils; @@ -24,6 +25,7 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; +import java.util.Collections; import java.util.List; /** @@ -69,7 +71,14 @@ public class MenuController { @ApiOperation(value = "查询当前登录用户的菜单", notes = "查询当前登录用户的菜单") @GetMapping("/myMenu") public List currentUserMenu() { - List list = menuService.list(Wrappers.lambdaQuery(Menu.class).orderByAsc(Menu::getSort)); + List roleIdList = LoginUserUtil.getRoleIdList(); + if (CollUtil.isEmpty(roleIdList)) { + return Collections.emptyList(); + } + String tmpSql = "(" + CollUtils.joinByComma(roleIdList) + ")"; + List list = menuService.list(Wrappers.lambdaQuery(Menu.class) + .exists("select 1 from nd_role_menu nur where nur.menu_id = nd_menu.id and nur.role_id in " + tmpSql) + .orderByAsc(Menu::getSort)); return menuManage.buildUserMenu(list); }