@Override
public List<MenuTreeList> menuTreeList() {
// 查出没有父级角色信息
List<MenuTreeList> parentRoleList = sysMenuMapper.getParentRoleList("0");
// 获取子级角色信息
parentRoleList = treeMenuList(parentRoleList);
// 使用递归方法获取
return parentRoleList;
}
private List<MenuTreeList> treeMenuList(List<MenuTreeList> parentRoleList) {
List<MenuTreeList> childList = new ArrayList<>();
for (MenuTreeList menuTree : parentRoleList) {
childList = sysMenuMapper.getParentRoleList(menuTree.getCode());
if (childList != null && childList.size() > 0) {
menuTree.setMenuTreeList(treeMenuList(childList));
}
}
return parentRoleList;
}
java递归树方法
最新推荐文章于 2024-01-09 20:31:27 发布