fix(基础功能): 解决根节点id可能为空的问题 (#224)

This commit is contained in:
Zhang Ji
2023-08-17 18:32:51 +08:00
committed by GitHub
parent e918889e7d
commit ce655e7fcb

View File

@@ -184,11 +184,6 @@ public interface TreeSupportEntity<PK> extends Entity {
}
}
if (CollectionUtils.isEmpty(root.getChildren())) {
target.add(root);
return;
}
//尝试设置id
PK parentId = root.getId();
if (parentId == null) {
@@ -196,6 +191,11 @@ public interface TreeSupportEntity<PK> extends Entity {
root.setId(parentId);
}
if (CollectionUtils.isEmpty(root.getChildren())) {
target.add(root);
return;
}
//所有节点处理队列
Queue<T> queue = new LinkedList<>();
queue.add(root);