照着谷粒商城做什么都没错为什么错在这种一脸懵的bug上,为什么视频展开到最后一级手机就可以选择手机,为什么我的最后一级手机还可以展开啊?
心态大蹦
谷粒商城-品牌管理-关联分类中新增关联选取不了数据,如图点手机还有下一级。
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
3条回答 默认 最新
cbx942213 2022-04-02 10:13关注改成这样就行了:
private List<PmsCategory> getChildren(PmsCategory root, List<PmsCategory> all) { List<PmsCategory> children = all.stream().filter(categoryEntity -> { // 找到当前id的子菜单 return categoryEntity.getParentCid().equals(root.getCatId()); }).map(categoryEntity -> { // 1 找到子菜单,递归找法 List<PmsCategory> res = getChildren(categoryEntity, all); if(res==null||res.size()==0){ categoryEntity.setChildren(null); }else{ categoryEntity.setChildren(res); } // categoryEntity.setChildren(getChildren(categoryEntity, all)); return categoryEntity; }).sorted((menu1, menu2) -> { // 2 菜单排序 return menu1.getSort() - menu2.getSort(); // menu1.getSort()==null?0;menu1.getSort() }).collect(Collectors.toList()); return children; }那个==改成equals是idea提示包装类应采用equals比较相等,不改也不报错
本回答被题主选为最佳回答 , 对您是否有帮助呢?评论 打赏 举报 编辑记录解决 2无用