递归获取树形标题
/**
* 获取当前节点的所有节点
*
* @param repositoryCode
* @return
*/
public DocumentsRepositoryVOtestTree(String projectCode,String repositoryCode)throws BizException {
if (StringUtils.isBlank(projectCode) || StringUtils.isBlank(repositoryCode)) {
throw new BizException(Constants.PARAMCODE, "未获取到数据!");
}
try {
//获取根目录
DocumentsRepositoryDO documentsRepositoryDO =documentsRepositoryMapper.selectByDocumentsRepositoryCode(repositoryCode);
//获取根目录下所有目录
List documentsRepositoryDOS =documentsRepositoryMapper.selectByProjectCode(projectCode);
firstReps.setChildren(getChildrenDir(documentsRepositoryVOS,repositoryCode));
return firstReps;
}catch (Exception e) {
throw new BizException(Constants.ERRCODE,"树形出错了");
}
}
//递归获取
public ListgetChildrenDir(List documentsRepositoryVOs, String repositoryParentCode) {
List result =new ArrayList<>();
for (DocumentsRepositoryVO documentsRepositoryVO : documentsRepositoryVOs) {
if (documentsRepositoryVO ==null) {
continue;
}
if(Objects.equals(documentsRepositoryVO.getRepositoryParentCode(),repositoryParentCode)){
documentsRepositoryVO.setChildren(getChildrenDir(documentsRepositoryVOs,documentsRepositoryVO.getRepositoryCode()));
result.add(documentsRepositoryVO);
}
}
return result;
}