public class JobCategory extends BaseEntity
{
private static final long serialVersionUID = 1L;
private Long id;
@Excel(name = "父级id")
private Long parentId;
@Excel(name = "类别名称")
private String categoryName;
@Excel(name = "类别描述")
private String categoryDesc;
@Excel(name = "岗位类别状态", readConverterExp = "0=正常,1=停用")
private String status;
private String delFlag;
private List<JobCategory> Children;
public List<JobCategory> queryTreeList(JobCategory jobCategory) {
List<JobCategory> list = jobCategoryMapper.selectJobCategoryList(jobCategory);
return list.stream().filter(m -> m.getParentId() == 0).peek(
(m) -> m.setChildren(getChildrenList(m, list))
).collect(Collectors.toList());
}
public static List<JobCategory> getChildrenList(JobCategory tree, List<JobCategory> list){
return list.stream().filter(item -> Objects.equals(item.getParentId(), tree.getId())).peek(
(item) -> item.setChildren(getChildrenList(item, list))
).collect(Collectors.toList());
}