//查询的数据
List<AssessmentVO> assessmentVOS = rickAssessmentDao.getAssessmentTree(isType);
// 2.配置
TreeNodeConfig config = new TreeNodeConfig();
//默认为id可以不设置
config.setIdKey("id");
//默认为parentId可以不设置
config.setParentIdKey("parentId");
//最大递归深度
config.setDeep(5);
//排序字段
config.setWeightKey("id");
List<Tree<String>> list = TreeUtil.build(assessmentVOS, "0", (node, tree) -> {
tree.setId(node.getId().toString());
tree.setName(node.getAssessmentName());
tree.setParentId(node.getParentId().toString());
// 额外的值
tree.put("weightNo",node.getWeightNo());
});
huttol 树状结构使用
最新推荐文章于 2024-01-17 14:38:54 发布