feat: 资料中心你顶层目录能看到子集目录中的文件
This commit is contained in:
+38
-1
@@ -33,6 +33,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,7 +80,10 @@ public class LawsDataCenterFileServiceImpl extends ServiceImpl<LawsDataCenterFil
|
|||||||
queryWrapper.between("create_time",
|
queryWrapper.between("create_time",
|
||||||
DateUtil.getDateSecond(timeArr[0]), DateUtil.getDateSecond(timeArr[1]));
|
DateUtil.getDateSecond(timeArr[0]), DateUtil.getDateSecond(timeArr[1]));
|
||||||
}
|
}
|
||||||
queryWrapper.eq(StringUtils.isNotBlank(lawsDataCenterFile.getFolderId()), "folder_id", lawsDataCenterFile.getFolderId());
|
// 找到所有子集文件夹Id
|
||||||
|
List<String> folderIdList = this.getAllChildFolderId(lawsDataCenterFile.getFolderId());
|
||||||
|
folderIdList.add(lawsDataCenterFile.getFolderId());
|
||||||
|
queryWrapper.in(StringUtils.isNotBlank(lawsDataCenterFile.getFolderId()), "folder_id", folderIdList);
|
||||||
List<String> adminRoleCodeList = Arrays.asList(adminRoleCode.split(","));
|
List<String> adminRoleCodeList = Arrays.asList(adminRoleCode.split(","));
|
||||||
Collection<String> intersection = CollectionUtils.intersection(Arrays.asList(CurrentUserUtil.getRoles().split(",")), adminRoleCodeList);
|
Collection<String> intersection = CollectionUtils.intersection(Arrays.asList(CurrentUserUtil.getRoles().split(",")), adminRoleCodeList);
|
||||||
String userId = CurrentUserUtil.getId();
|
String userId = CurrentUserUtil.getId();
|
||||||
@@ -109,6 +113,39 @@ public class LawsDataCenterFileServiceImpl extends ServiceImpl<LawsDataCenterFil
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<String> getAllChildFolderId(String folderId) {
|
||||||
|
List<String> folderIdList = new java.util.ArrayList<>();
|
||||||
|
|
||||||
|
if (StringUtils.isBlank(folderId)){
|
||||||
|
return folderIdList;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取所有parentId等于folderId的数据
|
||||||
|
List<LawsDataCenterFolder> folderList = lawsDataCenterFolderService.list(new QueryWrapper<LawsDataCenterFolder>()
|
||||||
|
.eq("parent_id", folderId));
|
||||||
|
|
||||||
|
if (folderList != null) {
|
||||||
|
folderIdList.addAll(folderList.stream()
|
||||||
|
.map(LawsDataCenterFolder::getId)
|
||||||
|
.filter(Objects::nonNull) // 确保 ID 不为 null
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 遍历子文件夹ID并递归调用,避免在迭代时修改集合
|
||||||
|
List<String> newFolderIds = new java.util.ArrayList<>(); // 用于存储新的子文件夹 ID
|
||||||
|
for (String f : folderIdList) {
|
||||||
|
List<String> childFolderIds = getAllChildFolderId(f);
|
||||||
|
if (!childFolderIds.isEmpty()) {
|
||||||
|
newFolderIds.addAll(childFolderIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 在迭代完成后,再批量添加子文件夹 ID
|
||||||
|
folderIdList.addAll(newFolderIds);
|
||||||
|
|
||||||
|
return folderIdList;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存
|
* 保存
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user