@JwtIgnore
@ApiOperation(value = "树结构信息", notes = "开发中")
@PostMapping("/treeNode")
public ResponseResult<?> tree(@RequestBody TreeTableRequest request) {
List<TreeTable> list = treeTableService.list();
List<TreeTableResponse> treeTableResponses = TreeTableConvert.INSTANCE.entityToResponseBatch(list);
//2.配置
TreeNodeConfig config = new TreeNodeConfig();
config.setIdKey("id"); //默认id,可以不设置
config.setParentIdKey("parentId"); //父id
config.setNameKey("name"); //分类名称
config.setDeep(3); //最大递归深度
config.setChildrenKey("children"); //孩子节点
config.setWeightKey("id");
List<Tree<String>> treeList = TreeUtil.build(treeTableResponses, null, config, ((object, treeNode) -> {
treeNode.putExtra("id", object.getId());
treeNode.putExtra("parentId", object.getParentId());
treeNode.putExtra("name", object.getName());
treeNode.putExtra("createTime", object.getCreateTime());
treeNode.putExtra("phone", object.getPhone());
}));
return ResponseResult.success(treeList);
}