폴더 목록 조회 --> 폴더명 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.config.api.ApiResponseDto;
|
||||||
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto;
|
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.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.SrchFilesDto;
|
||||||
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.SrchFoldersDto;
|
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.SrchFoldersDto;
|
||||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
||||||
@@ -44,7 +45,7 @@ public class MapSheetMngApiController {
|
|||||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||||
})
|
})
|
||||||
@PostMapping("/folder-list")
|
@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));
|
return ApiResponseDto.createOK(mapSheetMngService.getFolderAll(srchDto));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,15 +40,17 @@ public class FileDto {
|
|||||||
private final int depth;
|
private final int depth;
|
||||||
private final long childCnt;
|
private final long childCnt;
|
||||||
private final String lastModified;
|
private final String lastModified;
|
||||||
|
private final Boolean isValid;
|
||||||
|
|
||||||
public FolderDto(
|
public FolderDto(
|
||||||
String folderNm,
|
String folderNm,
|
||||||
String parentFolderNm,
|
String parentFolderNm,
|
||||||
String parentPath,
|
String parentPath,
|
||||||
String fullPath,
|
String fullPath,
|
||||||
int depth,
|
int depth,
|
||||||
long childCnt,
|
long childCnt,
|
||||||
String lastModified) {
|
String lastModified,
|
||||||
|
Boolean isValid) {
|
||||||
this.folderNm = folderNm;
|
this.folderNm = folderNm;
|
||||||
this.parentFolderNm = parentFolderNm;
|
this.parentFolderNm = parentFolderNm;
|
||||||
this.parentPath = parentPath;
|
this.parentPath = parentPath;
|
||||||
@@ -56,9 +58,29 @@ public class FileDto {
|
|||||||
this.depth = depth;
|
this.depth = depth;
|
||||||
this.childCnt = childCnt;
|
this.childCnt = childCnt;
|
||||||
this.lastModified = lastModified;
|
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 = "파일 기본 정보")
|
@Schema(name = "File Basic", description = "파일 기본 정보")
|
||||||
@Getter
|
@Getter
|
||||||
public static class Basic {
|
public static class Basic {
|
||||||
@@ -70,7 +92,7 @@ public class FileDto {
|
|||||||
private final String lastModified;
|
private final String lastModified;
|
||||||
|
|
||||||
public Basic(
|
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.fileNm = fileNm;
|
||||||
this.filePath = filePath;
|
this.filePath = filePath;
|
||||||
this.extension = extension;
|
this.extension = extension;
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package com.kamco.cd.kamcoback.mapsheet.service;
|
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;
|
||||||
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.FilesDto;
|
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.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.SrchFilesDto;
|
||||||
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.SrchFoldersDto;
|
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.SrchFoldersDto;
|
||||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
||||||
@@ -35,13 +37,17 @@ public class MapSheetMngService {
|
|||||||
|
|
||||||
private final MapSheetMngCoreService mapSheetMngCoreService;
|
private final MapSheetMngCoreService mapSheetMngCoreService;
|
||||||
|
|
||||||
public List<FolderDto> getFolderAll(SrchFoldersDto srchDto) {
|
|
||||||
|
public FoldersDto getFolderAll(SrchFoldersDto srchDto) {
|
||||||
|
|
||||||
Path startPath = Paths.get(srchDto.getDirPath());
|
Path startPath = Paths.get(srchDto.getDirPath());
|
||||||
String dirPath = srchDto.getDirPath();
|
String dirPath = srchDto.getDirPath();
|
||||||
|
|
||||||
int maxDepth = 1;
|
int maxDepth = 1;
|
||||||
|
|
||||||
|
int folderTotCnt = 0;
|
||||||
|
int folderErrTotCnt = 0;
|
||||||
|
|
||||||
List<FolderDto> folderDtoList = List.of();
|
List<FolderDto> folderDtoList = List.of();
|
||||||
SimpleDateFormat dttmFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat dttmFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
@@ -61,6 +67,12 @@ public class MapSheetMngService {
|
|||||||
String parentPath = path.getParent().toString();
|
String parentPath = path.getParent().toString();
|
||||||
String fullPath = path.toAbsolutePath().toString();
|
String fullPath = path.toAbsolutePath().toString();
|
||||||
|
|
||||||
|
boolean isValid = true;
|
||||||
|
if( NameValidator.containsKorean(folderNm) ||
|
||||||
|
NameValidator.containsWhitespaceRegex(folderNm) ){
|
||||||
|
isValid = false;
|
||||||
|
}
|
||||||
|
|
||||||
File directory = new File(fullPath);
|
File directory = new File(fullPath);
|
||||||
File[] childFolders = directory.listFiles(File::isDirectory);
|
File[] childFolders = directory.listFiles(File::isDirectory);
|
||||||
|
|
||||||
@@ -86,7 +98,9 @@ public class MapSheetMngService {
|
|||||||
fullPath,
|
fullPath,
|
||||||
depth,
|
depth,
|
||||||
childCnt,
|
childCnt,
|
||||||
lastModified);
|
lastModified,
|
||||||
|
isValid
|
||||||
|
);
|
||||||
|
|
||||||
return folderDto;
|
return folderDto;
|
||||||
})
|
})
|
||||||
@@ -98,11 +112,19 @@ public class MapSheetMngService {
|
|||||||
)
|
)
|
||||||
.reversed());
|
.reversed());
|
||||||
|
|
||||||
|
folderTotCnt = folderDtoList.size();
|
||||||
|
|
||||||
|
folderErrTotCnt = (int)folderDtoList.stream()
|
||||||
|
.filter(dto -> dto.getIsValid().toString().equals("false") )
|
||||||
|
.count();
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return folderDtoList;
|
FoldersDto foldersDto = new FoldersDto(dirPath, folderTotCnt, folderErrTotCnt, folderDtoList);
|
||||||
|
|
||||||
|
return foldersDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FilesDto getFilesAll(SrchFilesDto srchDto) {
|
public FilesDto getFilesAll(SrchFilesDto srchDto) {
|
||||||
|
|||||||
Reference in New Issue
Block a user