@Override标签:paths,递归,List,Long,findParentPath,catelogId,笔记,byId From: https://www.cnblogs.com/sensenh/p/16932587.html
public Long[] findCatelogPath(Long catelogId) {
List<Long> paths = new ArrayList<>();
List<Long> parentPath = findParentPath(catelogId, paths);
Collections.reverse(parentPath);
return (Long[]) parentPath.toArray();
}
private List<Long> findParentPath(Long catelogId, List<Long> paths) {
//收集当前节点id
paths.add(catelogId);
CategoryEntity byId = this.getById(catelogId);
if(byId.getParentCid() != 0) {
findParentPath(byId.getParentCid(), paths)
}
return paths;
}