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); }