fix 修复 TreeBuildUtils 顶节点不为 0 问题
This commit is contained in:
parent
df6759b033
commit
a62d65a9b8
@ -22,13 +22,8 @@ public class TreeBuildUtils extends TreeUtil {
|
|||||||
*/
|
*/
|
||||||
public static final TreeNodeConfig DEFAULT_CONFIG = TreeNodeConfig.DEFAULT_CONFIG.setNameKey("label");
|
public static final TreeNodeConfig DEFAULT_CONFIG = TreeNodeConfig.DEFAULT_CONFIG.setNameKey("label");
|
||||||
|
|
||||||
/**
|
public static <T> List<Tree<Long>> build(List<T> list, Long parentId, NodeParser<T, Long> nodeParser) {
|
||||||
* 默认树父节点id
|
return TreeUtil.build(list, parentId, DEFAULT_CONFIG, nodeParser);
|
||||||
*/
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,11 @@ public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept,
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Tree<Long>> buildDeptTreeSelect(List<SysDept> depts) {
|
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())
|
tree.setId(dept.getDeptId())
|
||||||
.setParentId(dept.getParentId())
|
.setParentId(dept.getParentId())
|
||||||
.setName(dept.getDeptName())
|
.setName(dept.getDeptName())
|
||||||
|
@ -178,7 +178,11 @@ public class SysMenuServiceImpl extends ServicePlusImpl<SysMenuMapper, SysMenu,
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Tree<Long>> buildMenuTreeSelect(List<SysMenu> menus) {
|
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())
|
tree.setId(menu.getMenuId())
|
||||||
.setParentId(menu.getParentId())
|
.setParentId(menu.getParentId())
|
||||||
.setName(menu.getMenuName())
|
.setName(menu.getMenuName())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user