我自己设计的层级菜单结构,层级不受限制
数据库表结构设计
/** * 第二种方法 * 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; }
本文来自博客园,作者:狂躁的键盘,转载请注明原文链接:https://www.cnblogs.com/wangweiip/p/16684350.html