@Override
public
List<CategoryVO> listForUser(){
ArrayList<CategoryVO> arrayList =
new
ArrayList<>();
System.out.println(arrayList.toString());
recursiveFindCategory(
0
,arrayList);
System.out.println(arrayList.toString());
return
arrayList;
}
private
void
recursiveFindCategory(Integer parentId,List<CategoryVO> categoryVOList){
List<Category> categoryList = categoryMapper.selectByParentId(parentId);
if
(!CollectionUtils.isEmpty(categoryList)){
for
(
int
i =
0
; i < categoryList.size(); i++) {
Category category = categoryList.get(i);
CategoryVO categoryVO =
new
CategoryVO();
BeanUtils.copyProperties(category,categoryVO);
categoryVOList.add(categoryVO);
recursiveFindCategory(categoryVO.getId(),categoryVO.getChildCategory());
}
}
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧