jwt 미적용으로 수정, spotlessApply 적용
This commit is contained in:
@@ -69,25 +69,23 @@ public class MapSheetMngApiController {
|
||||
|
||||
@Operation(summary = "파일목록 조회", description = "파일목록 조회")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
responseCode = "200",
|
||||
description = "조회 성공",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = CommonCodeDto.Basic.class))),
|
||||
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
value = {
|
||||
@ApiResponse(
|
||||
responseCode = "200",
|
||||
description = "조회 성공",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = CommonCodeDto.Basic.class))),
|
||||
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@PostMapping("/file-all-list")
|
||||
public ApiResponseDto<FilesDto> getAllFiles(@RequestBody SrchFilesDto srchDto) {
|
||||
|
||||
return ApiResponseDto.createOK(mapSheetMngService.getFilesDepthAll(srchDto));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 오류데이터 목록 조회
|
||||
*
|
||||
|
||||
@@ -24,15 +24,24 @@ public class FileDto {
|
||||
@AllArgsConstructor
|
||||
public static class SrchFilesDto {
|
||||
@Schema(description = "디렉토리경로", example = "/data")
|
||||
@NotNull private String dirPath;
|
||||
@NotNull
|
||||
private String dirPath;
|
||||
|
||||
@Schema(description = "전체(*), cpg,dbf,geojson등", example = "*")
|
||||
@NotNull private String extension;
|
||||
@NotNull
|
||||
private String extension;
|
||||
|
||||
@Schema(description = "파일명(name), 최종수정일(date)", example = "name")
|
||||
@NotNull private String sortType;
|
||||
@NotNull
|
||||
private String sortType;
|
||||
|
||||
@Schema(description = "파일시작위치", example = "1")
|
||||
@NotNull private Integer startPos;
|
||||
@NotNull
|
||||
private Integer startPos;
|
||||
|
||||
@Schema(description = "파일종료위치", example = "100")
|
||||
@NotNull private Integer endPos;
|
||||
@NotNull
|
||||
private Integer endPos;
|
||||
}
|
||||
|
||||
@Schema(name = "FolderDto", description = "폴더 정보")
|
||||
@@ -48,14 +57,14 @@ public class FileDto {
|
||||
private final Boolean isValid;
|
||||
|
||||
public FolderDto(
|
||||
String folderNm,
|
||||
String parentFolderNm,
|
||||
String parentPath,
|
||||
String fullPath,
|
||||
int depth,
|
||||
long childCnt,
|
||||
String lastModified,
|
||||
Boolean isValid) {
|
||||
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;
|
||||
@@ -75,7 +84,8 @@ public class FileDto {
|
||||
private final int folderErrTotCnt;
|
||||
private final List<FolderDto> folders;
|
||||
|
||||
public FoldersDto(String dirPath, int folderTotCnt, int folderErrTotCnt, List<FolderDto> folders) {
|
||||
public FoldersDto(
|
||||
String dirPath, int folderTotCnt, int folderErrTotCnt, List<FolderDto> folders) {
|
||||
|
||||
this.dirPath = dirPath;
|
||||
this.folderTotCnt = folderTotCnt;
|
||||
@@ -84,8 +94,6 @@ public class FileDto {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Schema(name = "File Basic", description = "파일 기본 정보")
|
||||
@Getter
|
||||
public static class Basic {
|
||||
@@ -99,7 +107,13 @@ public class FileDto {
|
||||
private final String lastModified;
|
||||
|
||||
public Basic(
|
||||
String fileNm, String parentFolderNm, String parentPath, String fullPath, String extension, long fileSize, String lastModified) {
|
||||
String fileNm,
|
||||
String parentFolderNm,
|
||||
String parentPath,
|
||||
String fullPath,
|
||||
String extension,
|
||||
long fileSize,
|
||||
String lastModified) {
|
||||
this.fileNm = fileNm;
|
||||
this.parentFolderNm = parentFolderNm;
|
||||
this.parentPath = parentPath;
|
||||
|
||||
@@ -40,7 +40,6 @@ public class MapSheetMngService {
|
||||
|
||||
private final MapSheetMngCoreService mapSheetMngCoreService;
|
||||
|
||||
|
||||
public FoldersDto getFolderAll(SrchFoldersDto srchDto) {
|
||||
|
||||
Path startPath = Paths.get(srchDto.getDirPath());
|
||||
@@ -70,8 +69,9 @@ public class MapSheetMngService {
|
||||
String parentPath = path.getParent().toString();
|
||||
String fullPath = path.toAbsolutePath().toString();
|
||||
|
||||
boolean isValid = !NameValidator.containsKorean(folderNm) &&
|
||||
!NameValidator.containsWhitespaceRegex(folderNm);
|
||||
boolean isValid =
|
||||
!NameValidator.containsKorean(folderNm)
|
||||
&& !NameValidator.containsWhitespaceRegex(folderNm);
|
||||
|
||||
File directory = new File(fullPath);
|
||||
File[] childFolders = directory.listFiles(File::isDirectory);
|
||||
@@ -91,15 +91,14 @@ public class MapSheetMngService {
|
||||
}
|
||||
|
||||
return new FolderDto(
|
||||
folderNm,
|
||||
parentFolderNm,
|
||||
parentPath,
|
||||
fullPath,
|
||||
depth,
|
||||
childCnt,
|
||||
lastModified,
|
||||
isValid
|
||||
);
|
||||
folderNm,
|
||||
parentFolderNm,
|
||||
parentPath,
|
||||
fullPath,
|
||||
depth,
|
||||
childCnt,
|
||||
lastModified,
|
||||
isValid);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -110,15 +109,18 @@ public class MapSheetMngService {
|
||||
.reversed());
|
||||
|
||||
folderTotCnt = folderDtoList.size();
|
||||
folderErrTotCnt = (int)folderDtoList.stream()
|
||||
.filter(dto -> dto.getIsValid().toString().equals("false") )
|
||||
.count();
|
||||
folderErrTotCnt =
|
||||
(int)
|
||||
folderDtoList.stream()
|
||||
.filter(dto -> dto.getIsValid().toString().equals("false"))
|
||||
.count();
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
// FoldersDto foldersDto = new FoldersDto(dirPath, folderTotCnt, folderErrTotCnt, folderDtoList);
|
||||
// FoldersDto foldersDto = new FoldersDto(dirPath, folderTotCnt, folderErrTotCnt,
|
||||
// folderDtoList);
|
||||
|
||||
return new FoldersDto(dirPath, folderTotCnt, folderErrTotCnt, folderDtoList);
|
||||
}
|
||||
@@ -167,7 +169,9 @@ public class MapSheetMngService {
|
||||
long fileSize = file.length();
|
||||
String lastModified = dttmFormat.format(new Date(file.lastModified()));
|
||||
|
||||
files.add(new FileDto.Basic(fileName, parentFolderNm, parentPath, fullPath, ext, fileSize, lastModified));
|
||||
files.add(
|
||||
new FileDto.Basic(
|
||||
fileName, parentFolderNm, parentPath, fullPath, ext, fileSize, lastModified));
|
||||
|
||||
fileTotCnt = fileTotCnt + 1;
|
||||
fileTotSize = fileTotSize + fileSize;
|
||||
@@ -182,15 +186,13 @@ public class MapSheetMngService {
|
||||
return filesDto;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public FilesDto getFilesDepthAll(SrchFilesDto srchDto) {
|
||||
|
||||
int maxDepth = 20;
|
||||
Path startPath = Paths.get(srchDto.getDirPath());
|
||||
String dirPath = srchDto.getDirPath();
|
||||
String extension = srchDto.getExtension();
|
||||
String sortType = srchDto.getSortType();
|
||||
String sortType = srchDto.getSortType();
|
||||
|
||||
Set<String> targetExtensions = createExtensionSet(extension);
|
||||
|
||||
@@ -203,37 +205,36 @@ public class MapSheetMngService {
|
||||
try (Stream<Path> stream = Files.walk(startPath, maxDepth)) {
|
||||
|
||||
fileDtoList =
|
||||
stream
|
||||
.filter(Files::isRegularFile)
|
||||
.filter(p -> extension == null ||
|
||||
extension.equals("") ||
|
||||
extension.equals("*") ||
|
||||
targetExtensions.contains(extractExtension(p))
|
||||
)
|
||||
.sorted(getFileComparator(sortType))
|
||||
.map(
|
||||
path -> {
|
||||
stream
|
||||
.filter(Files::isRegularFile)
|
||||
.filter(
|
||||
p ->
|
||||
extension == null
|
||||
|| extension.equals("")
|
||||
|| extension.equals("*")
|
||||
|| targetExtensions.contains(extractExtension(p)))
|
||||
.sorted(getFileComparator(sortType))
|
||||
.map(
|
||||
path -> {
|
||||
int depth = path.getNameCount();
|
||||
|
||||
int depth = path.getNameCount();
|
||||
String fileNm = path.getFileName().toString();
|
||||
String ext = FilenameUtils.getExtension(fileNm);
|
||||
String parentFolderNm = path.getParent().getFileName().toString();
|
||||
String parentPath = path.getParent().toString();
|
||||
String fullPath = path.toAbsolutePath().toString();
|
||||
|
||||
String fileNm = path.getFileName().toString();
|
||||
String ext = FilenameUtils.getExtension(fileNm);
|
||||
String parentFolderNm = path.getParent().getFileName().toString();
|
||||
String parentPath = path.getParent().toString();
|
||||
String fullPath = path.toAbsolutePath().toString();
|
||||
File file = new File(fullPath);
|
||||
long fileSize = file.length();
|
||||
String lastModified = dttmFormat.format(new Date(file.lastModified()));
|
||||
|
||||
File file = new File(fullPath);
|
||||
long fileSize = file.length();
|
||||
String lastModified = dttmFormat.format(new Date(file.lastModified()));
|
||||
|
||||
return new FileDto.Basic(fileNm, parentFolderNm, parentPath, fullPath, ext, fileSize, lastModified);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
return new FileDto.Basic(
|
||||
fileNm, parentFolderNm, parentPath, fullPath, ext, fileSize, lastModified);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
fileTotCnt = fileDtoList.size();
|
||||
fileTotSize = fileDtoList.stream()
|
||||
.mapToLong(FileDto.Basic::getFileSize)
|
||||
.sum();
|
||||
fileTotSize = fileDtoList.stream().mapToLong(FileDto.Basic::getFileSize).sum();
|
||||
|
||||
/*
|
||||
if( sort.equals("name")) {
|
||||
@@ -267,10 +268,10 @@ public class MapSheetMngService {
|
||||
|
||||
// "java, class" -> ["java", " class"] -> [".java", ".class"]
|
||||
return Arrays.stream(extensionString.split(","))
|
||||
.map(ext -> ext.trim())
|
||||
.filter(ext -> !ext.isEmpty())
|
||||
.map(ext -> "." + ext.toLowerCase())
|
||||
.collect(Collectors.toSet());
|
||||
.map(ext -> ext.trim())
|
||||
.filter(ext -> !ext.isEmpty())
|
||||
.map(ext -> "." + ext.toLowerCase())
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public String extractExtension(Path path) {
|
||||
@@ -278,7 +279,7 @@ public class MapSheetMngService {
|
||||
int lastDotIndex = filename.lastIndexOf('.');
|
||||
|
||||
// 확장자가 없거나 파일명이 .으로 끝나는 경우
|
||||
if (lastDotIndex == -1 || lastDotIndex == filename.length() - 1 ) {
|
||||
if (lastDotIndex == -1 || lastDotIndex == filename.length() - 1) {
|
||||
return ""; // 빈 문자열 반환
|
||||
}
|
||||
|
||||
@@ -286,24 +287,21 @@ public class MapSheetMngService {
|
||||
return filename.substring(lastDotIndex).toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
public Comparator<Path> getFileComparator(String sortType) {
|
||||
|
||||
// 파일 이름 비교 기본 Comparator (대소문자 무시)
|
||||
Comparator<Path> nameComparator = Comparator.comparing(
|
||||
path -> path.getFileName().toString(),
|
||||
CASE_INSENSITIVE_ORDER
|
||||
);
|
||||
Comparator<Path> nameComparator =
|
||||
Comparator.comparing(path -> path.getFileName().toString(), CASE_INSENSITIVE_ORDER);
|
||||
|
||||
Comparator<Path> dateComparator = Comparator.comparing(
|
||||
path -> {
|
||||
try {
|
||||
return Files.getLastModifiedTime(path);
|
||||
} catch (IOException e) {
|
||||
return FileTime.fromMillis(0);
|
||||
}
|
||||
}
|
||||
);
|
||||
Comparator<Path> dateComparator =
|
||||
Comparator.comparing(
|
||||
path -> {
|
||||
try {
|
||||
return Files.getLastModifiedTime(path);
|
||||
} catch (IOException e) {
|
||||
return FileTime.fromMillis(0);
|
||||
}
|
||||
});
|
||||
|
||||
if ("name desc".equalsIgnoreCase(sortType)) {
|
||||
return nameComparator.reversed();
|
||||
@@ -316,8 +314,6 @@ public class MapSheetMngService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList(
|
||||
MapSheetMngDto.@Valid searchReq searchReq) {
|
||||
return mapSheetMngCoreService.findMapSheetErrorList(searchReq);
|
||||
|
||||
Reference in New Issue
Block a user