폴더 목록 조회 --> 폴더명 validation 추가

This commit is contained in:
Harry M. You
2025-12-03 15:39:25 +09:00
parent b7962388a4
commit c3c484442e
3 changed files with 57 additions and 12 deletions

View File

@@ -1,8 +1,10 @@
package com.kamco.cd.kamcoback.mapsheet.service;
import com.kamco.cd.kamcoback.common.utils.NameValidator;
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.SrchFilesDto;
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.SrchFoldersDto;
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
@@ -35,13 +37,17 @@ public class MapSheetMngService {
private final MapSheetMngCoreService mapSheetMngCoreService;
public List<FolderDto> getFolderAll(SrchFoldersDto srchDto) {
public FoldersDto getFolderAll(SrchFoldersDto srchDto) {
Path startPath = Paths.get(srchDto.getDirPath());
String dirPath = srchDto.getDirPath();
int maxDepth = 1;
int folderTotCnt = 0;
int folderErrTotCnt = 0;
List<FolderDto> folderDtoList = List.of();
SimpleDateFormat dttmFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -61,6 +67,12 @@ public class MapSheetMngService {
String parentPath = path.getParent().toString();
String fullPath = path.toAbsolutePath().toString();
boolean isValid = true;
if( NameValidator.containsKorean(folderNm) ||
NameValidator.containsWhitespaceRegex(folderNm) ){
isValid = false;
}
File directory = new File(fullPath);
File[] childFolders = directory.listFiles(File::isDirectory);
@@ -86,7 +98,9 @@ public class MapSheetMngService {
fullPath,
depth,
childCnt,
lastModified);
lastModified,
isValid
);
return folderDto;
})
@@ -98,11 +112,19 @@ public class MapSheetMngService {
)
.reversed());
folderTotCnt = folderDtoList.size();
folderErrTotCnt = (int)folderDtoList.stream()
.filter(dto -> dto.getIsValid().toString().equals("false") )
.count();
} catch (IOException e) {
throw new RuntimeException(e);
}
return folderDtoList;
FoldersDto foldersDto = new FoldersDto(dirPath, folderTotCnt, folderErrTotCnt, folderDtoList);
return foldersDto;
}
public FilesDto getFilesAll(SrchFilesDto srchDto) {