【优化】字典tree接口精简冗余字段(sortCode、weight字段合并为sortCode)

pull/227/head
vchao 2024-07-16 17:27:22 +08:00 committed by 小诺
parent 58e7d743c4
commit a6424ca5ba
1 changed files with 6 additions and 1 deletions

View File

@ -16,7 +16,9 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollStreamUtil;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeNode;
import cn.hutool.core.lang.tree.TreeNodeConfig;
import cn.hutool.core.lang.tree.TreeUtil;
import cn.hutool.core.lang.tree.parser.DefaultNodeParser;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
@ -109,7 +111,10 @@ public class DevDictServiceImpl extends ServiceImpl<DevDictMapper, DevDict> impl
new TreeNode<>(devDict.getId(), devDict.getParentId(),
devDict.getDictLabel(), devDict.getSortCode()).setExtra(JSONUtil.parseObj(devDict)))
.collect(Collectors.toList());
return TreeUtil.build(treeNodeList, "0");
// 精简冗余字段(sortCode、weight字段合并)
TreeNodeConfig treeNodeConfig = new TreeNodeConfig();
treeNodeConfig.setWeightKey("sortCode");
return TreeUtil.build(treeNodeList, "0", treeNodeConfig, new DefaultNodeParser<>());
}
@Override