hutool 树结构 (方式一)
public List<Tree<String>> queryTree(QueryParams params) {
List<SystemOrganization> dataList = null;
TreeNodeConfig config = new TreeNodeConfig();
config.setIdKey("orgId");
config.setParentIdKey("parentId");
config.setNameKey("name");
config.setChildrenKey("children");
config.setWeightKey("ordinal");
List<Tree<String>> treeList = TreeUtil.build(dataList, "0", config, (data, treeNode) -> {
treeNode.setId(data.getId().toString());
treeNode.setParentId(data.getParentId().toString());
treeNode.setName(data.getName());
treeNode.putExtra("orgId", data.getOrgId());
treeNode.putExtra("ordinal", data.getOrdinal());
treeNode.putExtra("status", data.getStatus());
treeNode.putExtra("description", data.getDescription());
treeNode.putExtra("orgType", data.getOrgType());
});
return treeList;
}