From 6ede6b27b7c8d4ea5cbf4ec93b17b5f2358debf1 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期六, 13 三月 2021 09:46:59 +0800 Subject: [PATCH] # --- src/main/java/zy/cloud/wms/common/utils/TreeUtils.java | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 45 insertions(+), 0 deletions(-) diff --git a/src/main/java/zy/cloud/wms/common/utils/TreeUtils.java b/src/main/java/zy/cloud/wms/common/utils/TreeUtils.java index 43f36e7..717c8dd 100644 --- a/src/main/java/zy/cloud/wms/common/utils/TreeUtils.java +++ b/src/main/java/zy/cloud/wms/common/utils/TreeUtils.java @@ -4,7 +4,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Component; +import zy.cloud.wms.manager.entity.Node; import zy.cloud.wms.manager.entity.Tag; +import zy.cloud.wms.manager.service.NodeService; import zy.cloud.wms.manager.service.TagService; import java.util.*; @@ -18,6 +20,8 @@ @Autowired private TagService tagService; + @Autowired + private NodeService nodeService; /** * 鑾峰彇鏍戝浘鏁版嵁缁撴瀯 @@ -41,6 +45,27 @@ } /** + * 鑾峰彇鏍戝浘鏁版嵁缁撴瀯 + */ + @Cacheable(cacheNames="nodeTree",key="#id") + public ArrayList<Map> getNodeTree(String id){ + ArrayList<Map> result = new ArrayList<>(); + Node node = nodeService.selectById(id); + // 涓昏妭鐐� + Map<String, Object> map = new HashMap<>(); + map.put("title", node.getName()); + map.put("id", node.getId()); + map.put("spread", true); + List<Map> childrens = new ArrayList<>(); + map.put("children", childrens); + dealNode(node, childrens); + result.add(map); + // 寮�濮嬪鐞嗗瓧鑺傜偣 +// deal(tag, childrens); + return result; + } + + /** * 閫掑綊鑾峰彇瀛愯妭鐐规暟鎹� */ public void deal(Tag parent, List<Map> list) { @@ -60,6 +85,26 @@ } } + /** + * 閫掑綊鑾峰彇瀛愯妭鐐规暟鎹� + */ + public void dealNode(Node parent, List<Map> list) { + List<Node> nodes = nodeService.selectList( + new EntityWrapper<Node>() + .eq("parent_id", parent.getId()) + .eq("status", "1")); + for (Node node : nodes) { + Map<String, Object> map = new HashMap<>(); + map.put("title", node.getName()); + map.put("id", node.getId()); + map.put("spread", true); + List<Map> childrens = new ArrayList<>(); + map.put("children", childrens); + dealNode(node, childrens); + list.add(map); + } + } + -- Gitblit v1.9.1