파일목록 조회 Depth 추가

This commit is contained in:
Harry M. You
2025-12-04 11:36:28 +09:00
parent 345794ce69
commit bce49b7a0b
3 changed files with 29 additions and 24 deletions

View File

@@ -7,6 +7,7 @@ import com.kamco.cd.kamcoback.mapsheet.dto.FileDto;
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.FilesDto;
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.FolderDto;
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.FoldersDto;
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.SrchFilesDepthDto;
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.SrchFilesDto;
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.SrchFoldersDto;
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
@@ -181,19 +182,22 @@ public class MapSheetMngService {
}
}
FilesDto filesDto = new FilesDto(dirPath, fileTotCnt, fileTotSize, files);
return filesDto;
return new FilesDto(dirPath, fileTotCnt, fileTotSize, files);
}
public FilesDto getFilesDepthAll(SrchFilesDto srchDto) {
public FilesDto getFilesDepthAll(SrchFilesDepthDto srchDto) {
int maxDepth = 20;
Path startPath = Paths.get(srchDto.getDirPath());
int maxDepth = srchDto.getMaxDepth();
String dirPath = srchDto.getDirPath();
String extension = srchDto.getExtension();
String sortType = srchDto.getSortType();
int startPos = srchDto.getStartPos();
int endPos = srchDto.getEndPos();
int limit = endPos - startPos + 1;
Set<String> targetExtensions = createExtensionSet(extension);
List<FileDto.Basic> fileDtoList = new ArrayList<>();
@@ -202,6 +206,7 @@ public class MapSheetMngService {
int fileTotCnt = 0;
long fileTotSize = 0;
try (Stream<Path> stream = Files.walk(startPath, maxDepth)) {
fileDtoList =
@@ -214,6 +219,8 @@ public class MapSheetMngService {
|| extension.equals("*")
|| targetExtensions.contains(extractExtension(p)))
.sorted(getFileComparator(sortType))
.skip(startPos)
.limit(limit)
.map(
path -> {
int depth = path.getNameCount();
@@ -236,23 +243,7 @@ public class MapSheetMngService {
fileTotCnt = fileDtoList.size();
fileTotSize = fileDtoList.stream().mapToLong(FileDto.Basic::getFileSize).sum();
/*
if( sort.equals("name")) {
fileDtoList.sort(
Comparator.comparing(
FileDto.Basic::getFileNm, String.CASE_INSENSITIVE_ORDER
)
.reversed());
}
else if( sort.equals("date")) {
fileDtoList.sort(
Comparator.comparing(
FileDto.Basic::getLastModified
)
.reversed());
}
*/
} catch (IOException e) {
System.err.println("파일 I/O 오류 발생: " + e.getMessage());