From 4292c2c20a22da22e43bfbc981591b9d8daf966a Mon Sep 17 00:00:00 2001 From: WendyYang Date: Fri, 24 Mar 2023 17:48:50 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E7=94=A8=E6=88=B7=E6=9D=83?= =?UTF-8?q?=E9=99=90pid=E7=BD=AE=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ningdatech/pmapi/common/util/TreeUtil.java | 40 ++-------------------- 1 file changed, 3 insertions(+), 37 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/util/TreeUtil.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/util/TreeUtil.java index b693c87..64436ad 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/util/TreeUtil.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/util/TreeUtil.java @@ -65,6 +65,7 @@ public final class TreeUtil { List allIds = treeList.stream().map(node -> node.getId()).collect(Collectors.toList()); for (E baseNode : treeList) { if (!allIds.contains(baseNode.getPid()) || selfIdEqSelfParent.contains(baseNode.getPid())) { + baseNode.setPid(null); baseNode.setTopMenu(baseNode.getName()); trees.add(baseNode); } @@ -132,9 +133,10 @@ public final class TreeUtil { if (currMenus == null) { return Collections.emptyList(); } - ArrayList menus = new ArrayList<>(currMenus); + List menus = new ArrayList<>(currMenus); for (MenuRoleVO curr : currMenus) { if (curr.getPid().equals(StrPool.DEF_PARENT_ID)) { + curr.setPid(null); curr.setTopMenu(curr.getName()); } else { curr.setTopMenu(menuMap.get(curr.getPid()).getTopMenu()); @@ -153,40 +155,4 @@ public final class TreeUtil { return menus; } - - /** - * 动态判断redirect - * - * @param baseNode - */ - private static void checkRedirect(MenuRoleVO baseNode) { - checkMenuRedirect(baseNode, baseNode.getChildren()); - } - - private static Boolean checkMenuRedirect(MenuRoleVO baseNode, List menus) { - if (baseNode.getSize() > 0) { - for (MenuRoleVO menu : menus) { - if (menu.getPath().endsWith("Datav")) { - baseNode.setRedirect(menu.getComponent()); - return Boolean.TRUE; - } - - if (menu.getSize() == 0 && 0 == menu.getHidden()) { - baseNode.setRedirect(menu.getComponent()); - return Boolean.TRUE; - } - } - - //一轮没有合适的菜单 去三级菜单找 - for (MenuRoleVO menu : menus) { - if (menu.getSize() > 0) { - if (checkMenuRedirect(baseNode, menu.getChildren())) { - return Boolean.TRUE; - } - } - } - } - - return Boolean.FALSE; - } }