feat(系统设置): 构建模块树的方法中增加模块路径数据的构建
This commit is contained in:
parent
b5dca1b323
commit
7ab276d3b9
|
@ -67,6 +67,7 @@ public abstract class ModuleTreeService {
|
|||
List<BaseTreeNode> baseTreeNodeList = new ArrayList<>();
|
||||
if (haveVirtualRootNode) {
|
||||
BaseTreeNode defaultNode = this.getDefaultModule(virtualRootName);
|
||||
defaultNode.genModulePath(null);
|
||||
baseTreeNodeList.add(defaultNode);
|
||||
}
|
||||
int lastSize = 0;
|
||||
|
@ -75,18 +76,18 @@ public abstract class ModuleTreeService {
|
|||
lastSize = traverseList.size();
|
||||
List<BaseTreeNode> notMatchedList = new ArrayList<>();
|
||||
for (BaseTreeNode treeNode : traverseList) {
|
||||
if (StringUtils.equalsIgnoreCase(treeNode.getParentId(), ModuleConstants.ROOT_NODE_PARENT_ID)) {
|
||||
BaseTreeNode node = new BaseTreeNode(treeNode.getId(), treeNode.getName(), treeNode.getType(), treeNode.getParentId());
|
||||
baseTreeNodeList.add(node);
|
||||
baseTreeNodeMap.put(treeNode.getId(), node);
|
||||
} else {
|
||||
if (baseTreeNodeMap.containsKey(treeNode.getParentId())) {
|
||||
BaseTreeNode node = new BaseTreeNode(treeNode.getId(), treeNode.getName(), treeNode.getType(), treeNode.getParentId());
|
||||
baseTreeNodeMap.get(treeNode.getParentId()).addChild(node);
|
||||
baseTreeNodeMap.put(treeNode.getId(), node);
|
||||
} else {
|
||||
if (!baseTreeNodeMap.containsKey(treeNode.getParentId()) && !StringUtils.equals(treeNode.getParentId(), ModuleConstants.ROOT_NODE_PARENT_ID)) {
|
||||
notMatchedList.add(treeNode);
|
||||
continue;
|
||||
}
|
||||
BaseTreeNode node = new BaseTreeNode(treeNode.getId(), treeNode.getName(), treeNode.getType(), treeNode.getParentId());
|
||||
node.genModulePath(baseTreeNodeMap.get(treeNode.getParentId()));
|
||||
baseTreeNodeMap.put(treeNode.getId(), node);
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(treeNode.getParentId(), ModuleConstants.ROOT_NODE_PARENT_ID)) {
|
||||
baseTreeNodeList.add(node);
|
||||
} else if (baseTreeNodeMap.containsKey(treeNode.getParentId())) {
|
||||
baseTreeNodeMap.get(treeNode.getParentId()).addChild(node);
|
||||
}
|
||||
}
|
||||
traverseList = notMatchedList;
|
||||
|
|
|
@ -34,6 +34,17 @@ public class BaseTreeNode {
|
|||
@Schema(description = "节点资源数量(多数情况下不会随着节点信息返回,视接口而定)")
|
||||
private long count = 0;
|
||||
|
||||
@Schema(description = "节点路径(当前节点所在整棵树的路径)")
|
||||
private String path = "/";
|
||||
|
||||
public void genModulePath(BaseTreeNode parentNode) {
|
||||
if (parentNode != null) {
|
||||
path = parentNode.getPath() + "/" + this.getName();
|
||||
} else {
|
||||
path = "/" + this.getName();
|
||||
}
|
||||
}
|
||||
|
||||
public BaseTreeNode(String id, String name, String type) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
|
|
Loading…
Reference in New Issue