• java多级查询treeList展示代码


     

      @Override
        public List<MenuNode> treeList() {
            List<Menu> menuList = menuMapper.selectList(null);
            List<MenuNode> menuNodeList = menuList.stream().filter(menu -> menu.getParentId().equals(0))
                    .map(menu -> getMenuNodeObj(menu,menuList)).collect(Collectors.toList());
            return menuNodeList;
        }
    
        private MenuNode getMenuNodeObj(Menu menu, List<Menu> menuList) {
            MenuNode menuNode = new MenuNode();
            BeanUtils.copyProperties(menu,menuNode);
            List<MenuNode> nodeList = menuList.stream().filter(menu1 -> menu1.getParentId().equals(menu.getId()))
                    .map(menu1 -> getMenuNodeObj(menu1, menuList)).collect(Collectors.toList());
            menuNode.setChildren(nodeList);
            return menuNode;
        }
  • 相关阅读:
    Promise
    replace
    mongogogog
    sh back mongo
    mongodb 备份 还原 导出 导入
    mongo virtual
    openssl
    isMobile
    google api autocomplete
    npm
  • 原文地址:https://www.cnblogs.com/ljl5921/p/15466521.html
Copyright © 2020-2023  润新知