简易版
public List
//所有数据
List
List
return item.getParentCid() == 0; //过滤,找出所有没有父级的
}).map(menu -> {
menu.setChildList(getChildList(menu, entityList));//递归将设置子菜单
return menu;
}).sorted(Comparator.comparingInt(item -> (item.getSort() == null ? 0 :
item.getSort()))).collect(Collectors.toList());//排序
return collect;
}
private List
List
return item.getParentCid() == menu.getCatId();
}).map(child -> {
child.setChildList(getChildList(child, entityList));
return child;
}).sorted(Comparator.comparingInt(item -> (item.getSort() == null ? 0 : item.getSort()))).collect(Collectors.toList());
return collect;
}

浙公网安备 33010602011771号