我自己设计的层级菜单结构,层级不受限制

数据库表结构设计

 

 

 

 /**
     * 第二种方法
     * for循环会走平行路径
     */
    public static List<LtSpyOrganize>  tree(List<LtSpyOrganize> list) {
        for(LtSpyOrganize ltSpyOrganize  : list) {
            List<LtSpyOrganize> childList = new ArrayList<>();
            for(LtSpyOrganize organize : list) {
                if(ltSpyOrganize.getOrganizeId().equals( organize.getParentId())) {
                    childList.add(organize);
                }
            }
            ltSpyOrganize.setChildList(childList);
        }
  //过滤重复的 list
= list.stream().filter(p->p.getParentId() == 0).collect(Collectors.toList()); return list; }