一、功能描述
查找多级目录,返回结果如下
二、查询目录
1、先查询出一级目录,再递归查询多级目录
2、根据sortorder对目录进行排序
@Service
public class CategoryServiceImpl implements ICategoryService {
@Autowired
CategoryMapper categoryMapper;
@Override
public ResponseVO<List<CategoryVO>> selectAll() {
List<CategoryVO> categoryVOList = new ArrayList<>();
List<Category> categories = categoryMapper.selectAll();
for(Category category : categories){
if(category.getParentId().equals(ROOT_PARENT_ID)){
CategoryVO categoryVO = new CategoryVO();
BeanUtils.copyProperties(category, categoryVO);
categoryVOList.add(categoryVO);
}
}
categoryVOList.sort(Comparator.comparing(Category