폴더 목록 조회 --> 폴더명 validation 추가
This commit is contained in:
@@ -5,6 +5,7 @@ import com.kamco.cd.kamcoback.code.service.CommonCodeService;
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||
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.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;
|
||||
@@ -44,7 +45,7 @@ public class MapSheetMngApiController {
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@PostMapping("/folder-list")
|
||||
public ApiResponseDto<List<FileDto.FolderDto>> getDir(@RequestBody SrchFoldersDto srchDto) {
|
||||
public ApiResponseDto<FoldersDto> getDir(@RequestBody SrchFoldersDto srchDto) {
|
||||
return ApiResponseDto.createOK(mapSheetMngService.getFolderAll(srchDto));
|
||||
}
|
||||
|
||||
|
||||
@@ -40,15 +40,17 @@ public class FileDto {
|
||||
private final int depth;
|
||||
private final long childCnt;
|
||||
private final String lastModified;
|
||||
private final Boolean isValid;
|
||||
|
||||
public FolderDto(
|
||||
String folderNm,
|
||||
String parentFolderNm,
|
||||
String parentPath,
|
||||
String fullPath,
|
||||
int depth,
|
||||
long childCnt,
|
||||
String lastModified) {
|
||||
String folderNm,
|
||||
String parentFolderNm,
|
||||
String parentPath,
|
||||
String fullPath,
|
||||
int depth,
|
||||
long childCnt,
|
||||
String lastModified,
|
||||
Boolean isValid) {
|
||||
this.folderNm = folderNm;
|
||||
this.parentFolderNm = parentFolderNm;
|
||||
this.parentPath = parentPath;
|
||||
@@ -56,9 +58,29 @@ public class FileDto {
|
||||
this.depth = depth;
|
||||
this.childCnt = childCnt;
|
||||
this.lastModified = lastModified;
|
||||
this.isValid = isValid;
|
||||
}
|
||||
}
|
||||
|
||||
@Schema(name = "FoldersDto", description = "폴더목록 정보")
|
||||
@Getter
|
||||
public static class FoldersDto {
|
||||
private final String dirPath;
|
||||
private final int folderTotCnt;
|
||||
private final int folderErrTotCnt;
|
||||
private final List<FolderDto> folders;
|
||||
|
||||
public FoldersDto(String dirPath, int folderTotCnt, int folderErrTotCnt, List<FolderDto> folders) {
|
||||
|
||||
this.dirPath = dirPath;
|
||||
this.folderTotCnt = folderTotCnt;
|
||||
this.folderErrTotCnt = folderErrTotCnt;
|
||||
this.folders = folders;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Schema(name = "File Basic", description = "파일 기본 정보")
|
||||
@Getter
|
||||
public static class Basic {
|
||||
@@ -70,7 +92,7 @@ public class FileDto {
|
||||
private final String lastModified;
|
||||
|
||||
public Basic(
|
||||
String fileNm, String filePath, String extension, long fileSize, String lastModified) {
|
||||
String fileNm, String filePath, String extension, long fileSize, String lastModified) {
|
||||
this.fileNm = fileNm;
|
||||
this.filePath = filePath;
|
||||
this.extension = extension;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user