003 Lambda递归查询所有菜单树

Lambda递归查询所有菜单树

/**
 * 查询所有菜单树
 * JDK1.8
 */
private List getMenuTreeList(List menuList,String pid) {
    // 查找所有菜单
    List childrenList = new ArrayList<>();
            menuList.stream()
            .filter(d -> Objects.equals(pid, d.getParentId()))
            .collect(Collectors.toList())
            .forEach(d -> {
                //if(d.getMenuLeafNode().equals("0"))
                d.setChildMenu(getMenuTreeList(menuList,d.getId()));
                childrenList.add(d);
            });
    return childrenList;
}

你可能感兴趣的:(java)