jwt 미적용으로 수정, spotlessApply 적용
This commit is contained in:
@@ -103,8 +103,7 @@ public class CommonCodeDto {
|
|||||||
ZonedDateTime updatedDttm,
|
ZonedDateTime updatedDttm,
|
||||||
String props1,
|
String props1,
|
||||||
String props2,
|
String props2,
|
||||||
String props3
|
String props3) {
|
||||||
) {
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.code = code;
|
this.code = code;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
|||||||
@@ -291,7 +291,7 @@ public class GlobalExceptionHandler {
|
|||||||
@ResponseStatus(HttpStatus.CONFLICT)
|
@ResponseStatus(HttpStatus.CONFLICT)
|
||||||
@ExceptionHandler(DuplicateKeyException.class)
|
@ExceptionHandler(DuplicateKeyException.class)
|
||||||
public ApiResponseDto<String> handlerDuplicateKeyException(
|
public ApiResponseDto<String> handlerDuplicateKeyException(
|
||||||
DuplicateKeyException e, HttpServletRequest request) {
|
DuplicateKeyException e, HttpServletRequest request) {
|
||||||
log.warn("[DuplicateKeyException] resource :{} ", e.getMessage());
|
log.warn("[DuplicateKeyException] resource :{} ", e.getMessage());
|
||||||
|
|
||||||
String codeName = "DUPLICATE_DATA";
|
String codeName = "DUPLICATE_DATA";
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
|||||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||||
import org.springframework.security.config.http.SessionCreationPolicy;
|
import org.springframework.security.config.http.SessionCreationPolicy;
|
||||||
import org.springframework.security.web.SecurityFilterChain;
|
import org.springframework.security.web.SecurityFilterChain;
|
||||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebSecurity
|
@EnableWebSecurity
|
||||||
@@ -23,24 +22,30 @@ public class SecurityConfig {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||||
http.csrf(csrf -> csrf.disable())
|
http.csrf(csrf -> csrf.disable()) // CSRF 보안 기능 비활성화
|
||||||
.sessionManagement(sm -> sm.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
.sessionManagement(
|
||||||
.formLogin(form -> form.disable())
|
sm ->
|
||||||
.httpBasic(basic -> basic.disable())
|
sm.sessionCreationPolicy(
|
||||||
.logout(logout -> logout.disable())
|
SessionCreationPolicy.STATELESS)) // 서버 세션 만들지 않음 요청은 JWT 인증
|
||||||
// 🔥 여기서 우리가 만든 CustomAuthenticationProvider 하나만 등록
|
.formLogin(form -> form.disable()) // react에서 로그인 요청 관리
|
||||||
.authenticationProvider(customAuthenticationProvider)
|
.httpBasic(basic -> basic.disable()) // 기본 basic 인증 비활성화 JWT 인증사용
|
||||||
.authorizeHttpRequests(
|
.logout(logout -> logout.disable()) // 기본 로그아웃 비활성화 JWT는 서버 상태가 없으므로 로그아웃 처리 필요 없음
|
||||||
auth ->
|
.authenticationProvider(
|
||||||
auth.requestMatchers(
|
customAuthenticationProvider) // 로그인 패스워드 비교방식 스프링 기본 Provider 사용안함 커스텀 사용
|
||||||
"/api/auth/signin",
|
.authorizeHttpRequests(auth -> auth.anyRequest().permitAll());
|
||||||
"/api/auth/refresh",
|
// auth.requestMatchers(
|
||||||
"/swagger-ui/**",
|
// "/api/auth/signin",
|
||||||
"/v3/api-docs/**")
|
// "/api/auth/refresh",
|
||||||
.permitAll()
|
// "/swagger-ui/**",
|
||||||
.anyRequest()
|
// "/v3/api-docs/**") // 로그인 없이 접근가능 url
|
||||||
.authenticated())
|
// .permitAll()
|
||||||
.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);
|
// .anyRequest()
|
||||||
|
// .authenticated())
|
||||||
|
// .addFilterBefore(
|
||||||
|
// jwtAuthenticationFilter,
|
||||||
|
// UsernamePasswordAuthenticationFilter
|
||||||
|
// .class) // 요청 들어오면 먼저 JWT 토큰 검사 후 security context 에 사용자 정보 저장.
|
||||||
|
;
|
||||||
|
|
||||||
return http.build();
|
return http.build();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class GeoJsonDataService {
|
|||||||
|
|
||||||
/** GeoJSON 파일들을 데이터베이스에 저장 */
|
/** GeoJSON 파일들을 데이터베이스에 저장 */
|
||||||
public List<Long> processGeoJsonFiles(
|
public List<Long> processGeoJsonFiles(
|
||||||
Map<String, String> geoJsonContents, String archiveFileName) {
|
Map<String, String> geoJsonContents, String archiveFileName) {
|
||||||
List<Long> savedIds = new ArrayList<>();
|
List<Long> savedIds = new ArrayList<>();
|
||||||
|
|
||||||
log.info("GeoJSON 파일 처리 시작: {} ({}개 파일)", archiveFileName, geoJsonContents.size());
|
log.info("GeoJSON 파일 처리 시작: {} ({}개 파일)", archiveFileName, geoJsonContents.size());
|
||||||
@@ -54,10 +54,10 @@ public class GeoJsonDataService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.info(
|
log.info(
|
||||||
"GeoJSON 파일 처리 완료: {} (성공: {}개, 전체: {}개)",
|
"GeoJSON 파일 처리 완료: {} (성공: {}개, 전체: {}개)",
|
||||||
archiveFileName,
|
archiveFileName,
|
||||||
savedIds.size(),
|
savedIds.size(),
|
||||||
geoJsonContents.size());
|
geoJsonContents.size());
|
||||||
|
|
||||||
return savedIds;
|
return savedIds;
|
||||||
}
|
}
|
||||||
@@ -65,7 +65,7 @@ public class GeoJsonDataService {
|
|||||||
/** 개별 파일을 별도 트랜잭션으로 처리 */
|
/** 개별 파일을 별도 트랜잭션으로 처리 */
|
||||||
@Transactional
|
@Transactional
|
||||||
public Long processGeoJsonFileWithTransaction(
|
public Long processGeoJsonFileWithTransaction(
|
||||||
String fileName, String geoJsonContent, String archiveFileName) {
|
String fileName, String geoJsonContent, String archiveFileName) {
|
||||||
try {
|
try {
|
||||||
Long savedId = processGeoJsonFile(fileName, geoJsonContent, archiveFileName);
|
Long savedId = processGeoJsonFile(fileName, geoJsonContent, archiveFileName);
|
||||||
if (savedId != null && isLearningModelResult(fileName, geoJsonContent)) {
|
if (savedId != null && isLearningModelResult(fileName, geoJsonContent)) {
|
||||||
@@ -88,7 +88,7 @@ public class GeoJsonDataService {
|
|||||||
// 파일이 이미 처리되었는지 확인
|
// 파일이 이미 처리되었는지 확인
|
||||||
String dataPath = generateDataPath(archiveFileName, fileName);
|
String dataPath = generateDataPath(archiveFileName, fileName);
|
||||||
Optional<MapSheetLearnDataEntity> existingData =
|
Optional<MapSheetLearnDataEntity> existingData =
|
||||||
mapSheetLearnDataRepository.findByDataPath(dataPath);
|
mapSheetLearnDataRepository.findByDataPath(dataPath);
|
||||||
|
|
||||||
if (existingData.isPresent()) {
|
if (existingData.isPresent()) {
|
||||||
log.warn("이미 처리된 파일입니다: {}", dataPath);
|
log.warn("이미 처리된 파일입니다: {}", dataPath);
|
||||||
@@ -97,7 +97,7 @@ public class GeoJsonDataService {
|
|||||||
|
|
||||||
// 새 엔티티 생성 및 저장
|
// 새 엔티티 생성 및 저장
|
||||||
MapSheetLearnDataEntity entity =
|
MapSheetLearnDataEntity entity =
|
||||||
createMapSheetLearnDataEntity(fileName, geoJsonContent, archiveFileName, geoJsonNode);
|
createMapSheetLearnDataEntity(fileName, geoJsonContent, archiveFileName, geoJsonNode);
|
||||||
MapSheetLearnDataEntity savedEntity = mapSheetLearnDataRepository.save(entity);
|
MapSheetLearnDataEntity savedEntity = mapSheetLearnDataRepository.save(entity);
|
||||||
|
|
||||||
return savedEntity.getId();
|
return savedEntity.getId();
|
||||||
@@ -122,7 +122,7 @@ public class GeoJsonDataService {
|
|||||||
|
|
||||||
/** MapSheetLearnDataEntity 생성 */
|
/** MapSheetLearnDataEntity 생성 */
|
||||||
private MapSheetLearnDataEntity createMapSheetLearnDataEntity(
|
private MapSheetLearnDataEntity createMapSheetLearnDataEntity(
|
||||||
String fileName, String geoJsonContent, String archiveFileName, JsonNode geoJsonNode) {
|
String fileName, String geoJsonContent, String archiveFileName, JsonNode geoJsonNode) {
|
||||||
|
|
||||||
MapSheetLearnDataEntity entity = new MapSheetLearnDataEntity();
|
MapSheetLearnDataEntity entity = new MapSheetLearnDataEntity();
|
||||||
|
|
||||||
@@ -287,8 +287,8 @@ public class GeoJsonDataService {
|
|||||||
JsonNode properties = firstFeature.get("properties");
|
JsonNode properties = firstFeature.get("properties");
|
||||||
// 학습 모델 특화 필드 확인
|
// 학습 모델 특화 필드 확인
|
||||||
return properties.has("cd_prob")
|
return properties.has("cd_prob")
|
||||||
|| properties.has("class")
|
|| properties.has("class")
|
||||||
|| (properties.has("before") && properties.has("after"));
|
|| (properties.has("before") && properties.has("after"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -301,7 +301,7 @@ public class GeoJsonDataService {
|
|||||||
|
|
||||||
/** 학습 모델 결과의 geometry 데이터 처리 - 최적화된 배치 처리 */
|
/** 학습 모델 결과의 geometry 데이터 처리 - 최적화된 배치 처리 */
|
||||||
public void processLearningModelGeometryOptimized(
|
public void processLearningModelGeometryOptimized(
|
||||||
Long dataUid, String geoJsonContent, String fileName) {
|
Long dataUid, String geoJsonContent, String fileName) {
|
||||||
try {
|
try {
|
||||||
log.info("학습 모델 geometry 데이터 처리 시작: {} (dataUid: {})", fileName, dataUid);
|
log.info("학습 모델 geometry 데이터 처리 시작: {} (dataUid: {})", fileName, dataUid);
|
||||||
|
|
||||||
@@ -309,7 +309,7 @@ public class GeoJsonDataService {
|
|||||||
|
|
||||||
// 메타데이터 추출
|
// 메타데이터 추출
|
||||||
String mapSheetName =
|
String mapSheetName =
|
||||||
rootNode.has("name") ? rootNode.get("name").asText() : fileName.replace(".geojson", "");
|
rootNode.has("name") ? rootNode.get("name").asText() : fileName.replace(".geojson", "");
|
||||||
|
|
||||||
// 파일명에서 연도 및 지도번호 추출 (캠코_2021_2022_35813023)
|
// 파일명에서 연도 및 지도번호 추출 (캠코_2021_2022_35813023)
|
||||||
String[] parts = mapSheetName.split("_");
|
String[] parts = mapSheetName.split("_");
|
||||||
@@ -347,7 +347,7 @@ public class GeoJsonDataService {
|
|||||||
try {
|
try {
|
||||||
JsonNode feature = features.get(j);
|
JsonNode feature = features.get(j);
|
||||||
MapSheetLearnDataGeomEntity geomEntity =
|
MapSheetLearnDataGeomEntity geomEntity =
|
||||||
createGeometryEntity(feature, dataUid, beforeYear, afterYear, mapSheetNum);
|
createGeometryEntity(feature, dataUid, beforeYear, afterYear, mapSheetNum);
|
||||||
if (geomEntity != null) {
|
if (geomEntity != null) {
|
||||||
batch.add(geomEntity);
|
batch.add(geomEntity);
|
||||||
}
|
}
|
||||||
@@ -400,7 +400,7 @@ public class GeoJsonDataService {
|
|||||||
|
|
||||||
/** 개별 feature에서 geometry entity 생성 */
|
/** 개별 feature에서 geometry entity 생성 */
|
||||||
private MapSheetLearnDataGeomEntity createGeometryEntity(
|
private MapSheetLearnDataGeomEntity createGeometryEntity(
|
||||||
JsonNode feature, Long dataUid, String beforeYear, String afterYear, String mapSheetNum) {
|
JsonNode feature, Long dataUid, String beforeYear, String afterYear, String mapSheetNum) {
|
||||||
|
|
||||||
JsonNode properties = feature.get("properties");
|
JsonNode properties = feature.get("properties");
|
||||||
JsonNode geometry = feature.get("geometry");
|
JsonNode geometry = feature.get("geometry");
|
||||||
|
|||||||
@@ -69,25 +69,23 @@ public class MapSheetMngApiController {
|
|||||||
|
|
||||||
@Operation(summary = "파일목록 조회", description = "파일목록 조회")
|
@Operation(summary = "파일목록 조회", description = "파일목록 조회")
|
||||||
@ApiResponses(
|
@ApiResponses(
|
||||||
value = {
|
value = {
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
responseCode = "200",
|
responseCode = "200",
|
||||||
description = "조회 성공",
|
description = "조회 성공",
|
||||||
content =
|
content =
|
||||||
@Content(
|
@Content(
|
||||||
mediaType = "application/json",
|
mediaType = "application/json",
|
||||||
schema = @Schema(implementation = CommonCodeDto.Basic.class))),
|
schema = @Schema(implementation = CommonCodeDto.Basic.class))),
|
||||||
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
|
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
|
||||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||||
})
|
})
|
||||||
@PostMapping("/file-all-list")
|
@PostMapping("/file-all-list")
|
||||||
public ApiResponseDto<FilesDto> getAllFiles(@RequestBody SrchFilesDto srchDto) {
|
public ApiResponseDto<FilesDto> getAllFiles(@RequestBody SrchFilesDto srchDto) {
|
||||||
|
|
||||||
return ApiResponseDto.createOK(mapSheetMngService.getFilesDepthAll(srchDto));
|
return ApiResponseDto.createOK(mapSheetMngService.getFilesDepthAll(srchDto));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 오류데이터 목록 조회
|
* 오류데이터 목록 조회
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -24,15 +24,24 @@ public class FileDto {
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public static class SrchFilesDto {
|
public static class SrchFilesDto {
|
||||||
@Schema(description = "디렉토리경로", example = "/data")
|
@Schema(description = "디렉토리경로", example = "/data")
|
||||||
@NotNull private String dirPath;
|
@NotNull
|
||||||
|
private String dirPath;
|
||||||
|
|
||||||
@Schema(description = "전체(*), cpg,dbf,geojson등", example = "*")
|
@Schema(description = "전체(*), cpg,dbf,geojson등", example = "*")
|
||||||
@NotNull private String extension;
|
@NotNull
|
||||||
|
private String extension;
|
||||||
|
|
||||||
@Schema(description = "파일명(name), 최종수정일(date)", example = "name")
|
@Schema(description = "파일명(name), 최종수정일(date)", example = "name")
|
||||||
@NotNull private String sortType;
|
@NotNull
|
||||||
|
private String sortType;
|
||||||
|
|
||||||
@Schema(description = "파일시작위치", example = "1")
|
@Schema(description = "파일시작위치", example = "1")
|
||||||
@NotNull private Integer startPos;
|
@NotNull
|
||||||
|
private Integer startPos;
|
||||||
|
|
||||||
@Schema(description = "파일종료위치", example = "100")
|
@Schema(description = "파일종료위치", example = "100")
|
||||||
@NotNull private Integer endPos;
|
@NotNull
|
||||||
|
private Integer endPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Schema(name = "FolderDto", description = "폴더 정보")
|
@Schema(name = "FolderDto", description = "폴더 정보")
|
||||||
@@ -48,14 +57,14 @@ public class FileDto {
|
|||||||
private final Boolean isValid;
|
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) {
|
Boolean isValid) {
|
||||||
this.folderNm = folderNm;
|
this.folderNm = folderNm;
|
||||||
this.parentFolderNm = parentFolderNm;
|
this.parentFolderNm = parentFolderNm;
|
||||||
this.parentPath = parentPath;
|
this.parentPath = parentPath;
|
||||||
@@ -75,7 +84,8 @@ public class FileDto {
|
|||||||
private final int folderErrTotCnt;
|
private final int folderErrTotCnt;
|
||||||
private final List<FolderDto> folders;
|
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.dirPath = dirPath;
|
||||||
this.folderTotCnt = folderTotCnt;
|
this.folderTotCnt = folderTotCnt;
|
||||||
@@ -84,8 +94,6 @@ public class FileDto {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Schema(name = "File Basic", description = "파일 기본 정보")
|
@Schema(name = "File Basic", description = "파일 기본 정보")
|
||||||
@Getter
|
@Getter
|
||||||
public static class Basic {
|
public static class Basic {
|
||||||
@@ -99,7 +107,13 @@ public class FileDto {
|
|||||||
private final String lastModified;
|
private final String lastModified;
|
||||||
|
|
||||||
public Basic(
|
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.fileNm = fileNm;
|
||||||
this.parentFolderNm = parentFolderNm;
|
this.parentFolderNm = parentFolderNm;
|
||||||
this.parentPath = parentPath;
|
this.parentPath = parentPath;
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ public class MapSheetMngService {
|
|||||||
|
|
||||||
private final MapSheetMngCoreService mapSheetMngCoreService;
|
private final MapSheetMngCoreService mapSheetMngCoreService;
|
||||||
|
|
||||||
|
|
||||||
public FoldersDto getFolderAll(SrchFoldersDto srchDto) {
|
public FoldersDto getFolderAll(SrchFoldersDto srchDto) {
|
||||||
|
|
||||||
Path startPath = Paths.get(srchDto.getDirPath());
|
Path startPath = Paths.get(srchDto.getDirPath());
|
||||||
@@ -70,8 +69,9 @@ 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 = !NameValidator.containsKorean(folderNm) &&
|
boolean isValid =
|
||||||
!NameValidator.containsWhitespaceRegex(folderNm);
|
!NameValidator.containsKorean(folderNm)
|
||||||
|
&& !NameValidator.containsWhitespaceRegex(folderNm);
|
||||||
|
|
||||||
File directory = new File(fullPath);
|
File directory = new File(fullPath);
|
||||||
File[] childFolders = directory.listFiles(File::isDirectory);
|
File[] childFolders = directory.listFiles(File::isDirectory);
|
||||||
@@ -91,15 +91,14 @@ public class MapSheetMngService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new FolderDto(
|
return new FolderDto(
|
||||||
folderNm,
|
folderNm,
|
||||||
parentFolderNm,
|
parentFolderNm,
|
||||||
parentPath,
|
parentPath,
|
||||||
fullPath,
|
fullPath,
|
||||||
depth,
|
depth,
|
||||||
childCnt,
|
childCnt,
|
||||||
lastModified,
|
lastModified,
|
||||||
isValid
|
isValid);
|
||||||
);
|
|
||||||
})
|
})
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
@@ -110,15 +109,18 @@ public class MapSheetMngService {
|
|||||||
.reversed());
|
.reversed());
|
||||||
|
|
||||||
folderTotCnt = folderDtoList.size();
|
folderTotCnt = folderDtoList.size();
|
||||||
folderErrTotCnt = (int)folderDtoList.stream()
|
folderErrTotCnt =
|
||||||
.filter(dto -> dto.getIsValid().toString().equals("false") )
|
(int)
|
||||||
.count();
|
folderDtoList.stream()
|
||||||
|
.filter(dto -> dto.getIsValid().toString().equals("false"))
|
||||||
|
.count();
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(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);
|
return new FoldersDto(dirPath, folderTotCnt, folderErrTotCnt, folderDtoList);
|
||||||
}
|
}
|
||||||
@@ -167,7 +169,9 @@ public class MapSheetMngService {
|
|||||||
long fileSize = file.length();
|
long fileSize = file.length();
|
||||||
String lastModified = dttmFormat.format(new Date(file.lastModified()));
|
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;
|
fileTotCnt = fileTotCnt + 1;
|
||||||
fileTotSize = fileTotSize + fileSize;
|
fileTotSize = fileTotSize + fileSize;
|
||||||
@@ -182,15 +186,13 @@ public class MapSheetMngService {
|
|||||||
return filesDto;
|
return filesDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public FilesDto getFilesDepthAll(SrchFilesDto srchDto) {
|
public FilesDto getFilesDepthAll(SrchFilesDto srchDto) {
|
||||||
|
|
||||||
int maxDepth = 20;
|
int maxDepth = 20;
|
||||||
Path startPath = Paths.get(srchDto.getDirPath());
|
Path startPath = Paths.get(srchDto.getDirPath());
|
||||||
String dirPath = srchDto.getDirPath();
|
String dirPath = srchDto.getDirPath();
|
||||||
String extension = srchDto.getExtension();
|
String extension = srchDto.getExtension();
|
||||||
String sortType = srchDto.getSortType();
|
String sortType = srchDto.getSortType();
|
||||||
|
|
||||||
Set<String> targetExtensions = createExtensionSet(extension);
|
Set<String> targetExtensions = createExtensionSet(extension);
|
||||||
|
|
||||||
@@ -203,37 +205,36 @@ public class MapSheetMngService {
|
|||||||
try (Stream<Path> stream = Files.walk(startPath, maxDepth)) {
|
try (Stream<Path> stream = Files.walk(startPath, maxDepth)) {
|
||||||
|
|
||||||
fileDtoList =
|
fileDtoList =
|
||||||
stream
|
stream
|
||||||
.filter(Files::isRegularFile)
|
.filter(Files::isRegularFile)
|
||||||
.filter(p -> extension == null ||
|
.filter(
|
||||||
extension.equals("") ||
|
p ->
|
||||||
extension.equals("*") ||
|
extension == null
|
||||||
targetExtensions.contains(extractExtension(p))
|
|| extension.equals("")
|
||||||
)
|
|| extension.equals("*")
|
||||||
.sorted(getFileComparator(sortType))
|
|| targetExtensions.contains(extractExtension(p)))
|
||||||
.map(
|
.sorted(getFileComparator(sortType))
|
||||||
path -> {
|
.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();
|
File file = new File(fullPath);
|
||||||
String ext = FilenameUtils.getExtension(fileNm);
|
long fileSize = file.length();
|
||||||
String parentFolderNm = path.getParent().getFileName().toString();
|
String lastModified = dttmFormat.format(new Date(file.lastModified()));
|
||||||
String parentPath = path.getParent().toString();
|
|
||||||
String fullPath = path.toAbsolutePath().toString();
|
|
||||||
|
|
||||||
File file = new File(fullPath);
|
return new FileDto.Basic(
|
||||||
long fileSize = file.length();
|
fileNm, parentFolderNm, parentPath, fullPath, ext, fileSize, lastModified);
|
||||||
String lastModified = dttmFormat.format(new Date(file.lastModified()));
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
return new FileDto.Basic(fileNm, parentFolderNm, parentPath, fullPath, ext, fileSize, lastModified);
|
|
||||||
})
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
fileTotCnt = fileDtoList.size();
|
fileTotCnt = fileDtoList.size();
|
||||||
fileTotSize = fileDtoList.stream()
|
fileTotSize = fileDtoList.stream().mapToLong(FileDto.Basic::getFileSize).sum();
|
||||||
.mapToLong(FileDto.Basic::getFileSize)
|
|
||||||
.sum();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if( sort.equals("name")) {
|
if( sort.equals("name")) {
|
||||||
@@ -267,10 +268,10 @@ public class MapSheetMngService {
|
|||||||
|
|
||||||
// "java, class" -> ["java", " class"] -> [".java", ".class"]
|
// "java, class" -> ["java", " class"] -> [".java", ".class"]
|
||||||
return Arrays.stream(extensionString.split(","))
|
return Arrays.stream(extensionString.split(","))
|
||||||
.map(ext -> ext.trim())
|
.map(ext -> ext.trim())
|
||||||
.filter(ext -> !ext.isEmpty())
|
.filter(ext -> !ext.isEmpty())
|
||||||
.map(ext -> "." + ext.toLowerCase())
|
.map(ext -> "." + ext.toLowerCase())
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String extractExtension(Path path) {
|
public String extractExtension(Path path) {
|
||||||
@@ -278,7 +279,7 @@ public class MapSheetMngService {
|
|||||||
int lastDotIndex = filename.lastIndexOf('.');
|
int lastDotIndex = filename.lastIndexOf('.');
|
||||||
|
|
||||||
// 확장자가 없거나 파일명이 .으로 끝나는 경우
|
// 확장자가 없거나 파일명이 .으로 끝나는 경우
|
||||||
if (lastDotIndex == -1 || lastDotIndex == filename.length() - 1 ) {
|
if (lastDotIndex == -1 || lastDotIndex == filename.length() - 1) {
|
||||||
return ""; // 빈 문자열 반환
|
return ""; // 빈 문자열 반환
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,24 +287,21 @@ public class MapSheetMngService {
|
|||||||
return filename.substring(lastDotIndex).toLowerCase();
|
return filename.substring(lastDotIndex).toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Comparator<Path> getFileComparator(String sortType) {
|
public Comparator<Path> getFileComparator(String sortType) {
|
||||||
|
|
||||||
// 파일 이름 비교 기본 Comparator (대소문자 무시)
|
// 파일 이름 비교 기본 Comparator (대소문자 무시)
|
||||||
Comparator<Path> nameComparator = Comparator.comparing(
|
Comparator<Path> nameComparator =
|
||||||
path -> path.getFileName().toString(),
|
Comparator.comparing(path -> path.getFileName().toString(), CASE_INSENSITIVE_ORDER);
|
||||||
CASE_INSENSITIVE_ORDER
|
|
||||||
);
|
|
||||||
|
|
||||||
Comparator<Path> dateComparator = Comparator.comparing(
|
Comparator<Path> dateComparator =
|
||||||
path -> {
|
Comparator.comparing(
|
||||||
try {
|
path -> {
|
||||||
return Files.getLastModifiedTime(path);
|
try {
|
||||||
} catch (IOException e) {
|
return Files.getLastModifiedTime(path);
|
||||||
return FileTime.fromMillis(0);
|
} catch (IOException e) {
|
||||||
}
|
return FileTime.fromMillis(0);
|
||||||
}
|
}
|
||||||
);
|
});
|
||||||
|
|
||||||
if ("name desc".equalsIgnoreCase(sortType)) {
|
if ("name desc".equalsIgnoreCase(sortType)) {
|
||||||
return nameComparator.reversed();
|
return nameComparator.reversed();
|
||||||
@@ -316,8 +314,6 @@ public class MapSheetMngService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList(
|
public Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList(
|
||||||
MapSheetMngDto.@Valid searchReq searchReq) {
|
MapSheetMngDto.@Valid searchReq searchReq) {
|
||||||
return mapSheetMngCoreService.findMapSheetErrorList(searchReq);
|
return mapSheetMngCoreService.findMapSheetErrorList(searchReq);
|
||||||
|
|||||||
@@ -35,21 +35,36 @@ public class CommonCodeCoreService
|
|||||||
new EntityNotFoundException(
|
new EntityNotFoundException(
|
||||||
"parent id 를 찾을 수 없습니다. id : " + req.getParentId()));
|
"parent id 를 찾을 수 없습니다. id : " + req.getParentId()));
|
||||||
|
|
||||||
Long existsCount = commonCodeRepository.findByParentIdCodeExists(req.getParentId(), req.getCode());
|
Long existsCount =
|
||||||
|
commonCodeRepository.findByParentIdCodeExists(req.getParentId(), req.getCode());
|
||||||
if (existsCount > 0) {
|
if (existsCount > 0) {
|
||||||
throw new DuplicateKeyException("이미 등록되어 있습니다.");
|
throw new DuplicateKeyException("이미 등록되어 있습니다.");
|
||||||
}
|
}
|
||||||
|
|
||||||
CommonCodeEntity entity =
|
CommonCodeEntity entity =
|
||||||
new CommonCodeEntity(
|
new CommonCodeEntity(
|
||||||
req.getCode(), req.getName(), req.getDescription(), req.getOrder(), req.isUsed(), req.getProps1(), req.getProps2(), req.getProps3());
|
req.getCode(),
|
||||||
|
req.getName(),
|
||||||
|
req.getDescription(),
|
||||||
|
req.getOrder(),
|
||||||
|
req.isUsed(),
|
||||||
|
req.getProps1(),
|
||||||
|
req.getProps2(),
|
||||||
|
req.getProps3());
|
||||||
entity.addParent(parentCommonCodeEntity);
|
entity.addParent(parentCommonCodeEntity);
|
||||||
return commonCodeRepository.save(entity).toDto();
|
return commonCodeRepository.save(entity).toDto();
|
||||||
}
|
}
|
||||||
|
|
||||||
CommonCodeEntity entity =
|
CommonCodeEntity entity =
|
||||||
new CommonCodeEntity(
|
new CommonCodeEntity(
|
||||||
req.getCode(), req.getName(), req.getDescription(), req.getOrder(), req.isUsed(), req.getProps1(), req.getProps2(), req.getProps3());
|
req.getCode(),
|
||||||
|
req.getName(),
|
||||||
|
req.getDescription(),
|
||||||
|
req.getOrder(),
|
||||||
|
req.isUsed(),
|
||||||
|
req.getProps1(),
|
||||||
|
req.getProps2(),
|
||||||
|
req.getProps3());
|
||||||
return commonCodeRepository.save(entity).toDto();
|
return commonCodeRepository.save(entity).toDto();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +75,8 @@ public class CommonCodeCoreService
|
|||||||
.orElseThrow(() -> new EntityNotFoundException("common code 를 찾을 수 없습니다. id : " + id));
|
.orElseThrow(() -> new EntityNotFoundException("common code 를 찾을 수 없습니다. id : " + id));
|
||||||
|
|
||||||
Long parentId = found.getParent() == null ? null : found.getParent().getId();
|
Long parentId = found.getParent() == null ? null : found.getParent().getId();
|
||||||
Long existsCount = commonCodeRepository.findByParentIdCodeExiststoUpdate(id, parentId, req.getCode());
|
Long existsCount =
|
||||||
|
commonCodeRepository.findByParentIdCodeExiststoUpdate(id, parentId, req.getCode());
|
||||||
if (existsCount > 0) {
|
if (existsCount > 0) {
|
||||||
throw new DuplicateKeyException("이미 등록되어 있습니다.");
|
throw new DuplicateKeyException("이미 등록되어 있습니다.");
|
||||||
}
|
}
|
||||||
@@ -76,8 +92,7 @@ public class CommonCodeCoreService
|
|||||||
found.getDeleted(),
|
found.getDeleted(),
|
||||||
req.getProps1(),
|
req.getProps1(),
|
||||||
req.getProps2(),
|
req.getProps2(),
|
||||||
req.getProps3()
|
req.getProps3());
|
||||||
);
|
|
||||||
|
|
||||||
return commonCodeRepository.save(entity).toDto();
|
return commonCodeRepository.save(entity).toDto();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,14 @@ public class CommonCodeEntity extends CommonDateEntity {
|
|||||||
private String props3;
|
private String props3;
|
||||||
|
|
||||||
public CommonCodeEntity(
|
public CommonCodeEntity(
|
||||||
String code, String name, String description, Integer order, Boolean used, String props1, String props2, String props3) {
|
String code,
|
||||||
|
String name,
|
||||||
|
String description,
|
||||||
|
Integer order,
|
||||||
|
Boolean used,
|
||||||
|
String props1,
|
||||||
|
String props2,
|
||||||
|
String props3) {
|
||||||
this.code = code;
|
this.code = code;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
@@ -86,7 +93,16 @@ public class CommonCodeEntity extends CommonDateEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CommonCodeEntity(
|
public CommonCodeEntity(
|
||||||
Long id, String code, String name, String description, Integer order, Boolean used, Boolean deleted, String props1, String props2, String props3) {
|
Long id,
|
||||||
|
String code,
|
||||||
|
String name,
|
||||||
|
String description,
|
||||||
|
Integer order,
|
||||||
|
Boolean used,
|
||||||
|
Boolean deleted,
|
||||||
|
String props1,
|
||||||
|
String props2,
|
||||||
|
String props3) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.code = code;
|
this.code = code;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@@ -101,20 +117,19 @@ public class CommonCodeEntity extends CommonDateEntity {
|
|||||||
|
|
||||||
public CommonCodeDto.Basic toDto() {
|
public CommonCodeDto.Basic toDto() {
|
||||||
return new CommonCodeDto.Basic(
|
return new CommonCodeDto.Basic(
|
||||||
this.id,
|
this.id,
|
||||||
this.code,
|
this.code,
|
||||||
this.description,
|
this.description,
|
||||||
this.name,
|
this.name,
|
||||||
this.order,
|
this.order,
|
||||||
this.used,
|
this.used,
|
||||||
this.deleted,
|
this.deleted,
|
||||||
this.children.stream().map(CommonCodeEntity::toDto).toList(),
|
this.children.stream().map(CommonCodeEntity::toDto).toList(),
|
||||||
super.getCreatedDate(),
|
super.getCreatedDate(),
|
||||||
super.getModifiedDate(),
|
super.getModifiedDate(),
|
||||||
this.props1,
|
this.props1,
|
||||||
this.props2,
|
this.props2,
|
||||||
this.props3
|
this.props3);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addParent(CommonCodeEntity parent) {
|
public void addParent(CommonCodeEntity parent) {
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ public class MapSheetLearnDataEntity {
|
|||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "tb_map_sheet_learn_data_id_gen")
|
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "tb_map_sheet_learn_data_id_gen")
|
||||||
@SequenceGenerator(
|
@SequenceGenerator(
|
||||||
name = "tb_map_sheet_learn_data_id_gen",
|
name = "tb_map_sheet_learn_data_id_gen",
|
||||||
sequenceName = "tb_map_sheet_learn_data_data_uid",
|
sequenceName = "tb_map_sheet_learn_data_data_uid",
|
||||||
allocationSize = 1)
|
allocationSize = 1)
|
||||||
@Column(name = "data_uid", nullable = false)
|
@Column(name = "data_uid", nullable = false)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ public class MapSheetLearnDataGeomEntity {
|
|||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(
|
@GeneratedValue(
|
||||||
strategy = GenerationType.SEQUENCE,
|
strategy = GenerationType.SEQUENCE,
|
||||||
generator = "tb_map_sheet_learn_data_geom_id_gen")
|
generator = "tb_map_sheet_learn_data_geom_id_gen")
|
||||||
@SequenceGenerator(
|
@SequenceGenerator(
|
||||||
name = "tb_map_sheet_learn_data_geom_id_gen",
|
name = "tb_map_sheet_learn_data_geom_id_gen",
|
||||||
sequenceName = "tb_map_sheet_learn_data_geom_geom_uid",
|
sequenceName = "tb_map_sheet_learn_data_geom_geom_uid",
|
||||||
allocationSize = 1)
|
allocationSize = 1)
|
||||||
@Column(name = "geo_uid", nullable = false)
|
@Column(name = "geo_uid", nullable = false)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.kamco.cd.kamcoback.postgres.repository.code;
|
|||||||
import com.kamco.cd.kamcoback.code.dto.CommonCodeDto;
|
import com.kamco.cd.kamcoback.code.dto.CommonCodeDto;
|
||||||
import com.kamco.cd.kamcoback.postgres.entity.CommonCodeEntity;
|
import com.kamco.cd.kamcoback.postgres.entity.CommonCodeEntity;
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
|||||||
@@ -99,26 +99,22 @@ public class CommonCodeRepositoryImpl implements CommonCodeRepositoryCustom {
|
|||||||
@Override
|
@Override
|
||||||
public Long findByParentIdCodeExists(Long parentId, String code) {
|
public Long findByParentIdCodeExists(Long parentId, String code) {
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.select(commonCodeEntity.code.count())
|
.select(commonCodeEntity.code.count())
|
||||||
.from(commonCodeEntity)
|
.from(commonCodeEntity)
|
||||||
.where(
|
.where(commonCodeEntity.parent.id.eq(parentId), commonCodeEntity.code.eq(code))
|
||||||
commonCodeEntity.parent.id.eq(parentId),
|
.fetchOne();
|
||||||
commonCodeEntity.code.eq(code)
|
|
||||||
)
|
|
||||||
.fetchOne();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long findByParentIdCodeExiststoUpdate(Long id, Long parentId, String code) {
|
public Long findByParentIdCodeExiststoUpdate(Long id, Long parentId, String code) {
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.select(commonCodeEntity.code.count())
|
.select(commonCodeEntity.code.count())
|
||||||
.from(commonCodeEntity)
|
.from(commonCodeEntity)
|
||||||
.where(
|
.where(
|
||||||
commonCodeEntity.parent.id.eq(parentId),
|
commonCodeEntity.parent.id.eq(parentId),
|
||||||
commonCodeEntity.code.eq(code),
|
commonCodeEntity.code.eq(code),
|
||||||
commonCodeEntity.id.ne(id)
|
commonCodeEntity.id.ne(id))
|
||||||
)
|
.fetchOne();
|
||||||
.fetchOne();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<CommonCodeEntity> findAllByIds(Set<Long> ids) {
|
private List<CommonCodeEntity> findAllByIds(Set<Long> ids) {
|
||||||
|
|||||||
Reference in New Issue
Block a user