public class ProjectCategoryResp implements Serializable {
private static final long serialVersionUID = 6674128359897096742L;
/**主键*/
@ApiModelProperty(value = "主键")
private Long id;
/**项目分类名称*/
@ApiModelProperty(value = "项目分类名称")
private String name;
/**父id*/
@ApiModelProperty(value = "父id")
private Long parentId;
/**子类*/
@ApiModelProperty(value = "子类")
private List<ProjectCategoryResp> childrenCategorys;
}
private List<ProjectCategoryResp> handleProjectCategorysByRecursion(Long parentId,List<ProjectCategory> projectCategorys) {
List<ProjectCategoryResp> categoryResps = Lists.newArrayList();
for (ProjectCategory projectCategory : projectCategorys) {
if (!projectCategory.getParentId().equals(parentId)) {
continue;
}
ProjectCategoryResp categoryResp = BeanUtil.copyProperties(projectCategory,ProjectCategoryResp.class);
categoryResp.setChildrenCategorys(handleProjectCategorysByRecursion(projectCategory.getId(),projectCategorys));
categoryResps.add(categoryResp);
}
return categoryResps;
}