|
@@ -2,6 +2,7 @@ package com.gis.tree;
|
|
|
|
|
|
|
|
|
import com.gis.domain.entity.DirEntity;
|
|
|
+import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
@@ -37,8 +38,9 @@ public class DirTreeUtil {
|
|
|
*/
|
|
|
public List<DirTree> buildTree() {
|
|
|
for (DirTree node : nodes) {
|
|
|
- Long id = node.getParentId();
|
|
|
- if (id == null) {//通过循环一级节点 就可以通过递归获取二级以下节点
|
|
|
+ Long parentId = node.getParentId();
|
|
|
+ // 根节点id=1
|
|
|
+ if (parentId != null && parentId==1) {//通过循环一级节点 就可以通过递归获取二级以下节点
|
|
|
resultNodes.add(node);//添加一级节点
|
|
|
node.setLevel(1);
|
|
|
build(node, node.getLevel());//递归获取二级、三级、。。。节点
|
|
@@ -56,7 +58,7 @@ public class DirTreeUtil {
|
|
|
List<DirTree> children = getChildren(node);
|
|
|
if (!children.isEmpty()) {//如果存在子节点
|
|
|
node.setChildren(children);
|
|
|
-// level++;
|
|
|
+ level++;
|
|
|
for (DirTree child : children) {//将子节点遍历加入返回值中
|
|
|
child.setLevel(level);
|
|
|
build(child, child.getLevel());
|