资料库代码提交
This commit is contained in:
@@ -83,5 +83,8 @@ public class LibAlgorithm extends BaseEntity {
|
||||
@TableField(exist = false)
|
||||
private List<LibAlgorithm> children;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer level;
|
||||
|
||||
|
||||
}
|
||||
@@ -93,12 +93,14 @@ public class LibAlgorithmServiceImpl extends ServiceImpl<LibAlgorithmMapper, Lib
|
||||
|
||||
List<LibAlgorithm> libAlgorithmList = this.lambdaQuery().eq(LibAlgorithm::getStatus,1).list();
|
||||
List<LibAlgorithm> tree = libAlgorithmList.stream().filter(item -> item.getPid().equals("0")).peek(item -> {
|
||||
item.setLevel(1);
|
||||
item.setChildren(getChildren(item, libAlgorithmList));
|
||||
}).collect(Collectors.toList());
|
||||
return tree;
|
||||
}
|
||||
private List<LibAlgorithm> getChildren(LibAlgorithm libAlgorithm, List<LibAlgorithm> all) {
|
||||
return all.stream().filter(item -> item.getPid().equals(libAlgorithm.getId())).peek(item -> {
|
||||
item.setLevel(libAlgorithm.getLevel()+1);
|
||||
item.setChildren(getChildren(item, all));
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user