fix 修复 TreeBuildUtils 顶节点不为 0 问题
| | |
| | | */ |
| | | public static final TreeNodeConfig DEFAULT_CONFIG = TreeNodeConfig.DEFAULT_CONFIG.setNameKey("label"); |
| | | |
| | | /** |
| | | * 默认树父节点id |
| | | */ |
| | | public static final Long DEFAULT_PARENT_ID = 0L; |
| | | |
| | | public static <T> List<Tree<Long>> build(List<T> list, NodeParser<T, Long> nodeParser) { |
| | | return TreeUtil.build(list, DEFAULT_PARENT_ID, DEFAULT_CONFIG, nodeParser); |
| | | public static <T> List<Tree<Long>> build(List<T> list, Long parentId, NodeParser<T, Long> nodeParser) { |
| | | return TreeUtil.build(list, parentId, DEFAULT_CONFIG, nodeParser); |
| | | } |
| | | |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public List<Tree<Long>> buildDeptTreeSelect(List<SysDept> depts) { |
| | | return TreeBuildUtils.build(depts, (dept, tree) -> |
| | | if (CollUtil.isEmpty(depts)) { |
| | | return CollUtil.newArrayList(); |
| | | } |
| | | Long parentId = depts.get(0).getParentId(); |
| | | return TreeBuildUtils.build(depts, parentId, (dept, tree) -> |
| | | tree.setId(dept.getDeptId()) |
| | | .setParentId(dept.getParentId()) |
| | | .setName(dept.getDeptName()) |
| | |
| | | */ |
| | | @Override |
| | | public List<Tree<Long>> buildMenuTreeSelect(List<SysMenu> menus) { |
| | | return TreeBuildUtils.build(menus, (menu, tree) -> |
| | | if (CollUtil.isEmpty(menus)) { |
| | | return CollUtil.newArrayList(); |
| | | } |
| | | Long parentId = menus.get(0).getParentId(); |
| | | return TreeBuildUtils.build(menus, parentId, (menu, tree) -> |
| | | tree.setId(menu.getMenuId()) |
| | | .setParentId(menu.getParentId()) |
| | | .setName(menu.getMenuName()) |