|
|
@@ -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<MenuRoleVO> currentUserMenu() { |
|
|
|
List<Menu> list = menuService.list(Wrappers.lambdaQuery(Menu.class).orderByAsc(Menu::getSort)); |
|
|
|
List<Long> roleIdList = LoginUserUtil.getRoleIdList(); |
|
|
|
if (CollUtil.isEmpty(roleIdList)) { |
|
|
|
return Collections.emptyList(); |
|
|
|
} |
|
|
|
String tmpSql = "(" + CollUtils.joinByComma(roleIdList) + ")"; |
|
|
|
List<Menu> 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); |
|
|
|
} |
|
|
|
|
|
|
|