From 40f03ba1d05ab8c90cda8de1a59a9645a8035c27 Mon Sep 17 00:00:00 2001 From: hiparker Date: Thu, 6 May 2021 17:46:11 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8F=9C=E5=8D=95=E7=9B=B8=E5=85=B3=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/opsli/api/web/system/menu/MenuApi.java | 8 ++++---- .../system/menu/web/MenuRestController.java | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/opsli-api/src/main/java/org/opsli/api/web/system/menu/MenuApi.java b/opsli-api/src/main/java/org/opsli/api/web/system/menu/MenuApi.java index 8f9df22..57679b7 100644 --- a/opsli-api/src/main/java/org/opsli/api/web/system/menu/MenuApi.java +++ b/opsli-api/src/main/java/org/opsli/api/web/system/menu/MenuApi.java @@ -61,7 +61,7 @@ public interface MenuApi { /** * 懒加载列表菜单 * @param parentId 父节点ID - * @return + * @return ResultVo */ @GetMapping("/findMenuTreePageByLazy") ResultVo findMenuTreePageByLazy(String parentId); @@ -69,11 +69,11 @@ public interface MenuApi { /** * 懒加载菜单 * @param parentId 父节点ID - * @return + * @param id 自身ID (不为空 则排除自身) + * @return ResultVo */ @GetMapping("/findMenuTreeByLazy") - ResultVo findMenuTreeByLazy(String parentId); - + ResultVo findMenuTreeByLazy(String parentId, String id); /** * 获得当前用户登录菜单 diff --git a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/menu/web/MenuRestController.java b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/menu/web/MenuRestController.java index e19e4dd..2a503ec 100644 --- a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/menu/web/MenuRestController.java +++ b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/menu/web/MenuRestController.java @@ -167,13 +167,15 @@ public class MenuRestController extends BaseRestController findMenuTreeByLazy(String parentId) { + public ResultVo findMenuTreeByLazy(String parentId, String id) { List menuModelList; if(StringUtils.isEmpty(parentId)){ menuModelList = Lists.newArrayList(); @@ -190,9 +192,17 @@ public class MenuRestController extends BaseRestController queryBuilder = new GenQueryBuilder<>(); QueryWrapper queryWrapper = queryBuilder.build(); - queryWrapper.eq(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); + queryWrapper.eq( + HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); queryWrapper.eq("type", "1"); + // 如果传入ID 则不包含自身 + if(StringUtils.isNotEmpty(id)){ + queryWrapper.notIn( + HumpUtil.humpToUnderline(MyBatisConstants.FIELD_ID), id); + + } + // 获得菜单 List menuList = IService.findList(queryWrapper); menuModelList = WrapperUtil.transformInstance(menuList, MenuModel.class);