Merge pull request 'AccessDeniedException 401 -> 403 으로 변경' (#49) from feat/dev_251201 into develop

Reviewed-on: https://kamco.gitea.gs.dabeeo.com/dabeeo/kamco-dabeeo-backoffice/pulls/49
This commit is contained in:
2025-12-11 18:23:30 +09:00
17 changed files with 457 additions and 292 deletions

View File

@@ -22,13 +22,4 @@ public enum RoleType implements EnumType {
public String getText() { public String getText() {
return desc; return desc;
} }
public static RoleType from(String value) {
for (RoleType type : values()) {
if (type.name().equalsIgnoreCase(value)) {
return type;
}
}
return null;
}
} }

View File

@@ -0,0 +1,19 @@
package com.kamco.cd.kamcoback.common.utils;
import com.kamco.cd.kamcoback.config.enums.EnumType;
public class Enums {
// code로 text
public static <E extends Enum<E> & EnumType> E fromId(Class<E> enumClass, String id) {
if (id == null) {
return null;
}
for (E e : enumClass.getEnumConstants()) {
if (id.equalsIgnoreCase(e.getId())) {
return e;
}
}
return null; // 못 찾으면 null
}
}

View File

@@ -0,0 +1,18 @@
package com.kamco.cd.kamcoback.config;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/** GeoJSON 파일 모니터링 설정 */
@Component
@ConfigurationProperties(prefix = "file.config")
@Getter
@Setter
public class FileConfig {
private String rootSyncDir = "D:\\app\\original-images";
// private String rootSyncDir = "/app/original-images";
}

View File

@@ -45,197 +45,197 @@ public class GlobalExceptionHandler {
@ResponseStatus(HttpStatus.UNPROCESSABLE_ENTITY) @ResponseStatus(HttpStatus.UNPROCESSABLE_ENTITY)
@ExceptionHandler(EntityNotFoundException.class) @ExceptionHandler(EntityNotFoundException.class)
public ApiResponseDto<String> handlerEntityNotFoundException( public ApiResponseDto<String> handlerEntityNotFoundException(
EntityNotFoundException e, HttpServletRequest request) { EntityNotFoundException e, HttpServletRequest request) {
log.warn("[EntityNotFoundException] resource :{} ", e.getMessage()); log.warn("[EntityNotFoundException] resource :{} ", e.getMessage());
String codeName = "NOT_FOUND_DATA"; String codeName = "NOT_FOUND_DATA";
ErrorLogEntity errorLog = ErrorLogEntity errorLog =
saveErrorLogData( saveErrorLogData(
request, request,
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
HttpStatus.valueOf("UNPROCESSABLE_ENTITY"), HttpStatus.valueOf("UNPROCESSABLE_ENTITY"),
ErrorLogDto.LogErrorLevel.WARNING, ErrorLogDto.LogErrorLevel.WARNING,
e.getStackTrace()); e.getStackTrace());
return ApiResponseDto.createException( return ApiResponseDto.createException(
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
ApiResponseCode.getMessage(codeName), ApiResponseCode.getMessage(codeName),
HttpStatus.valueOf("UNPROCESSABLE_ENTITY"), HttpStatus.valueOf("UNPROCESSABLE_ENTITY"),
errorLog.getId()); errorLog.getId());
} }
@ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(HttpMessageNotReadableException.class) @ExceptionHandler(HttpMessageNotReadableException.class)
public ApiResponseDto<String> handleUnreadable( public ApiResponseDto<String> handleUnreadable(
HttpMessageNotReadableException e, HttpServletRequest request) { HttpMessageNotReadableException e, HttpServletRequest request) {
log.warn("[HttpMessageNotReadableException] resource :{} ", e.getMessage()); log.warn("[HttpMessageNotReadableException] resource :{} ", e.getMessage());
String codeName = "BAD_REQUEST"; String codeName = "BAD_REQUEST";
ErrorLogEntity errorLog = ErrorLogEntity errorLog =
saveErrorLogData( saveErrorLogData(
request, request,
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
HttpStatus.valueOf(codeName), HttpStatus.valueOf(codeName),
ErrorLogDto.LogErrorLevel.WARNING, ErrorLogDto.LogErrorLevel.WARNING,
e.getStackTrace()); e.getStackTrace());
return ApiResponseDto.createException( return ApiResponseDto.createException(
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
ApiResponseCode.getMessage(codeName), ApiResponseCode.getMessage(codeName),
HttpStatus.valueOf(codeName), HttpStatus.valueOf(codeName),
errorLog.getId()); errorLog.getId());
} }
@ResponseStatus(HttpStatus.NOT_FOUND) @ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(NoSuchElementException.class) @ExceptionHandler(NoSuchElementException.class)
public ApiResponseDto<String> handlerNoSuchElementException( public ApiResponseDto<String> handlerNoSuchElementException(
NoSuchElementException e, HttpServletRequest request) { NoSuchElementException e, HttpServletRequest request) {
log.warn("[NoSuchElementException] resource :{} ", e.getMessage()); log.warn("[NoSuchElementException] resource :{} ", e.getMessage());
String codeName = "NOT_FOUND_DATA"; String codeName = "NOT_FOUND_DATA";
ErrorLogEntity errorLog = ErrorLogEntity errorLog =
saveErrorLogData( saveErrorLogData(
request, request,
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
HttpStatus.valueOf(codeName), HttpStatus.valueOf(codeName),
ErrorLogDto.LogErrorLevel.WARNING, ErrorLogDto.LogErrorLevel.WARNING,
e.getStackTrace()); e.getStackTrace());
return ApiResponseDto.createException( return ApiResponseDto.createException(
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
ApiResponseCode.getMessage(codeName), ApiResponseCode.getMessage(codeName),
HttpStatus.valueOf("NOT_FOUND"), HttpStatus.valueOf("NOT_FOUND"),
errorLog.getId()); errorLog.getId());
} }
@ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(IllegalArgumentException.class) @ExceptionHandler(IllegalArgumentException.class)
public ApiResponseDto<String> handlerIllegalArgumentException( public ApiResponseDto<String> handlerIllegalArgumentException(
IllegalArgumentException e, HttpServletRequest request) { IllegalArgumentException e, HttpServletRequest request) {
log.warn("[handlerIllegalArgumentException] resource :{} ", e.getMessage()); log.warn("[handlerIllegalArgumentException] resource :{} ", e.getMessage());
String codeName = "BAD_REQUEST"; String codeName = "BAD_REQUEST";
ErrorLogEntity errorLog = ErrorLogEntity errorLog =
saveErrorLogData( saveErrorLogData(
request, request,
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
HttpStatus.valueOf(codeName), HttpStatus.valueOf(codeName),
ErrorLogDto.LogErrorLevel.WARNING, ErrorLogDto.LogErrorLevel.WARNING,
e.getStackTrace()); e.getStackTrace());
return ApiResponseDto.createException( return ApiResponseDto.createException(
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
ApiResponseCode.getMessage(codeName), ApiResponseCode.getMessage(codeName),
HttpStatus.valueOf(codeName), HttpStatus.valueOf(codeName),
errorLog.getId()); errorLog.getId());
} }
@ResponseStatus(HttpStatus.UNPROCESSABLE_ENTITY) @ResponseStatus(HttpStatus.UNPROCESSABLE_ENTITY)
@ExceptionHandler(DataIntegrityViolationException.class) @ExceptionHandler(DataIntegrityViolationException.class)
public ApiResponseDto<String> handlerDataIntegrityViolationException( public ApiResponseDto<String> handlerDataIntegrityViolationException(
DataIntegrityViolationException e, HttpServletRequest request) { DataIntegrityViolationException e, HttpServletRequest request) {
log.warn("[DataIntegrityViolationException] resource :{} ", e.getMessage()); log.warn("[DataIntegrityViolationException] resource :{} ", e.getMessage());
String codeName = "DATA_INTEGRITY_ERROR"; String codeName = "DATA_INTEGRITY_ERROR";
ErrorLogEntity errorLog = ErrorLogEntity errorLog =
saveErrorLogData( saveErrorLogData(
request, request,
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
HttpStatus.valueOf("UNPROCESSABLE_ENTITY"), HttpStatus.valueOf("UNPROCESSABLE_ENTITY"),
ErrorLogDto.LogErrorLevel.CRITICAL, ErrorLogDto.LogErrorLevel.CRITICAL,
e.getStackTrace()); e.getStackTrace());
return ApiResponseDto.createException( return ApiResponseDto.createException(
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
ApiResponseCode.getMessage(codeName), ApiResponseCode.getMessage(codeName),
HttpStatus.valueOf("UNPROCESSABLE_ENTITY"), HttpStatus.valueOf("UNPROCESSABLE_ENTITY"),
errorLog.getId()); errorLog.getId());
} }
@ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(MethodArgumentNotValidException.class) @ExceptionHandler(MethodArgumentNotValidException.class)
public ApiResponseDto<String> handlerMethodArgumentNotValidException( public ApiResponseDto<String> handlerMethodArgumentNotValidException(
MethodArgumentNotValidException e, HttpServletRequest request) { MethodArgumentNotValidException e, HttpServletRequest request) {
log.warn("[MethodArgumentNotValidException] resource :{} ", e.getMessage()); log.warn("[MethodArgumentNotValidException] resource :{} ", e.getMessage());
String codeName = "BAD_REQUEST"; String codeName = "BAD_REQUEST";
ErrorLogEntity errorLog = ErrorLogEntity errorLog =
saveErrorLogData( saveErrorLogData(
request, request,
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
HttpStatus.valueOf(codeName), HttpStatus.valueOf(codeName),
ErrorLogDto.LogErrorLevel.WARNING, ErrorLogDto.LogErrorLevel.WARNING,
e.getStackTrace()); e.getStackTrace());
return ApiResponseDto.createException( return ApiResponseDto.createException(
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
ApiResponseCode.getMessage(codeName), ApiResponseCode.getMessage(codeName),
HttpStatus.valueOf(codeName), HttpStatus.valueOf(codeName),
errorLog.getId()); errorLog.getId());
} }
@ResponseStatus(HttpStatus.UNAUTHORIZED) @ResponseStatus(HttpStatus.FORBIDDEN)
@ExceptionHandler(AccessDeniedException.class) @ExceptionHandler(AccessDeniedException.class)
public ApiResponseDto<String> handlerAccessDeniedException( public ApiResponseDto<String> handlerAccessDeniedException(
AccessDeniedException e, HttpServletRequest request) { AccessDeniedException e, HttpServletRequest request) {
log.warn("[AccessDeniedException] resource :{} ", e.getMessage()); log.warn("[AccessDeniedException] resource :{} ", e.getMessage());
String codeName = "UNAUTHORIZED"; String codeName = "FORBIDDEN";
ErrorLogEntity errorLog = ErrorLogEntity errorLog =
saveErrorLogData( saveErrorLogData(
request, request,
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
HttpStatus.valueOf(codeName), HttpStatus.valueOf(codeName),
ErrorLogDto.LogErrorLevel.ERROR, ErrorLogDto.LogErrorLevel.ERROR,
e.getStackTrace()); e.getStackTrace());
return ApiResponseDto.createException( return ApiResponseDto.createException(
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
ApiResponseCode.getMessage(codeName), ApiResponseCode.getMessage(codeName),
HttpStatus.valueOf(codeName), HttpStatus.valueOf(codeName),
errorLog.getId()); errorLog.getId());
} }
@ResponseStatus(HttpStatus.BAD_GATEWAY) @ResponseStatus(HttpStatus.BAD_GATEWAY)
@ExceptionHandler(HttpServerErrorException.BadGateway.class) @ExceptionHandler(HttpServerErrorException.BadGateway.class)
public ApiResponseDto<String> handlerHttpServerErrorException( public ApiResponseDto<String> handlerHttpServerErrorException(
HttpServerErrorException e, HttpServletRequest request) { HttpServerErrorException e, HttpServletRequest request) {
log.warn("[HttpServerErrorException] resource :{} ", e.getMessage()); log.warn("[HttpServerErrorException] resource :{} ", e.getMessage());
String codeName = "BAD_GATEWAY"; String codeName = "BAD_GATEWAY";
ErrorLogEntity errorLog = ErrorLogEntity errorLog =
saveErrorLogData( saveErrorLogData(
request, request,
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
HttpStatus.valueOf(codeName), HttpStatus.valueOf(codeName),
ErrorLogDto.LogErrorLevel.CRITICAL, ErrorLogDto.LogErrorLevel.CRITICAL,
e.getStackTrace()); e.getStackTrace());
return ApiResponseDto.createException( return ApiResponseDto.createException(
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
ApiResponseCode.getMessage(codeName), ApiResponseCode.getMessage(codeName),
HttpStatus.valueOf(codeName), HttpStatus.valueOf(codeName),
errorLog.getId()); errorLog.getId());
} }
@ResponseStatus(HttpStatus.UNPROCESSABLE_ENTITY) @ResponseStatus(HttpStatus.UNPROCESSABLE_ENTITY)
@ExceptionHandler(IllegalStateException.class) @ExceptionHandler(IllegalStateException.class)
public ApiResponseDto<String> handlerIllegalStateException( public ApiResponseDto<String> handlerIllegalStateException(
IllegalStateException e, HttpServletRequest request) { IllegalStateException e, HttpServletRequest request) {
log.warn("[IllegalStateException] resource :{} ", e.getMessage()); log.warn("[IllegalStateException] resource :{} ", e.getMessage());
String codeName = "UNPROCESSABLE_ENTITY"; String codeName = "UNPROCESSABLE_ENTITY";
ErrorLogEntity errorLog = ErrorLogEntity errorLog =
saveErrorLogData( saveErrorLogData(
request, request,
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
HttpStatus.valueOf(codeName), HttpStatus.valueOf(codeName),
ErrorLogDto.LogErrorLevel.WARNING, ErrorLogDto.LogErrorLevel.WARNING,
e.getStackTrace()); e.getStackTrace());
return ApiResponseDto.createException( return ApiResponseDto.createException(
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
ApiResponseCode.getMessage(codeName), ApiResponseCode.getMessage(codeName),
HttpStatus.valueOf(codeName), HttpStatus.valueOf(codeName),
errorLog.getId()); errorLog.getId());
} }
@ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(MemberException.DuplicateMemberException.class) @ExceptionHandler(MemberException.DuplicateMemberException.class)
public ApiResponseDto<String> handlerDuplicateMemberException( public ApiResponseDto<String> handlerDuplicateMemberException(
MemberException.DuplicateMemberException e, HttpServletRequest request) { MemberException.DuplicateMemberException e, HttpServletRequest request) {
log.warn("[DuplicateMemberException] resource :{} ", e.getMessage()); log.warn("[DuplicateMemberException] resource :{} ", e.getMessage());
String codeName = ""; String codeName = "";
@@ -250,112 +250,112 @@ public class GlobalExceptionHandler {
} }
ErrorLogEntity errorLog = ErrorLogEntity errorLog =
saveErrorLogData( saveErrorLogData(
request, request,
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
HttpStatus.valueOf("BAD_REQUEST"), HttpStatus.valueOf("BAD_REQUEST"),
ErrorLogDto.LogErrorLevel.WARNING, ErrorLogDto.LogErrorLevel.WARNING,
e.getStackTrace()); e.getStackTrace());
return ApiResponseDto.createException( return ApiResponseDto.createException(
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
ApiResponseCode.getMessage(codeName), ApiResponseCode.getMessage(codeName),
HttpStatus.valueOf("BAD_REQUEST"), HttpStatus.valueOf("BAD_REQUEST"),
errorLog.getId()); errorLog.getId());
} }
@ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(MemberException.MemberNotFoundException.class) @ExceptionHandler(MemberException.MemberNotFoundException.class)
public ApiResponseDto<String> handlerMemberNotFoundException( public ApiResponseDto<String> handlerMemberNotFoundException(
MemberException.MemberNotFoundException e, HttpServletRequest request) { MemberException.MemberNotFoundException e, HttpServletRequest request) {
log.warn("[MemberNotFoundException] resource :{} ", e.getMessage()); log.warn("[MemberNotFoundException] resource :{} ", e.getMessage());
String codeName = "NOT_FOUND_USER"; String codeName = "NOT_FOUND_USER";
ErrorLogEntity errorLog = ErrorLogEntity errorLog =
saveErrorLogData( saveErrorLogData(
request, request,
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
HttpStatus.valueOf("BAD_REQUEST"), HttpStatus.valueOf("BAD_REQUEST"),
ErrorLogDto.LogErrorLevel.WARNING, ErrorLogDto.LogErrorLevel.WARNING,
e.getStackTrace()); e.getStackTrace());
return ApiResponseDto.createException( return ApiResponseDto.createException(
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
ApiResponseCode.getMessage(codeName), ApiResponseCode.getMessage(codeName),
HttpStatus.valueOf("BAD_REQUEST"), HttpStatus.valueOf("BAD_REQUEST"),
errorLog.getId()); errorLog.getId());
} }
@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";
ErrorLogEntity errorLog = ErrorLogEntity errorLog =
saveErrorLogData( saveErrorLogData(
request, request,
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
HttpStatus.valueOf("CONFLICT"), HttpStatus.valueOf("CONFLICT"),
ErrorLogDto.LogErrorLevel.WARNING, ErrorLogDto.LogErrorLevel.WARNING,
e.getStackTrace()); e.getStackTrace());
return ApiResponseDto.createException( return ApiResponseDto.createException(
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
ApiResponseCode.getMessage(codeName), ApiResponseCode.getMessage(codeName),
HttpStatus.valueOf("CONFLICT"), HttpStatus.valueOf("CONFLICT"),
errorLog.getId()); errorLog.getId());
} }
@ExceptionHandler(BadCredentialsException.class) @ExceptionHandler(BadCredentialsException.class)
public ResponseEntity<ApiResponseDto<String>> handleBadCredentials( public ResponseEntity<ApiResponseDto<String>> handleBadCredentials(
BadCredentialsException e, HttpServletRequest request) { BadCredentialsException e, HttpServletRequest request) {
log.warn("[BadCredentialsException] resource : {} ", e.getMessage()); log.warn("[BadCredentialsException] resource : {} ", e.getMessage());
String codeName = "UNAUTHORIZED"; String codeName = "UNAUTHORIZED";
ErrorLogEntity errorLog = ErrorLogEntity errorLog =
saveErrorLogData( saveErrorLogData(
request, request,
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
HttpStatus.valueOf(codeName), HttpStatus.valueOf(codeName),
ErrorLogDto.LogErrorLevel.WARNING, ErrorLogDto.LogErrorLevel.WARNING,
e.getStackTrace()); e.getStackTrace());
ApiResponseDto<String> body = ApiResponseDto<String> body =
ApiResponseDto.createException( ApiResponseDto.createException(
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
ApiResponseCode.getMessage(codeName), ApiResponseCode.getMessage(codeName),
HttpStatus.valueOf(codeName), HttpStatus.valueOf(codeName),
errorLog.getId()); errorLog.getId());
return ResponseEntity.status(HttpStatus.UNAUTHORIZED) // 🔥 여기서 401 지정 return ResponseEntity.status(HttpStatus.UNAUTHORIZED) // 🔥 여기서 401 지정
.body(body); .body(body);
} }
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(RuntimeException.class) @ExceptionHandler(RuntimeException.class)
public ApiResponseDto<String> handlerRuntimeException( public ApiResponseDto<String> handlerRuntimeException(
RuntimeException e, HttpServletRequest request) { RuntimeException e, HttpServletRequest request) {
log.warn("[RuntimeException] resource :{} ", e.getMessage()); log.warn("[RuntimeException] resource :{} ", e.getMessage());
String codeName = "INTERNAL_SERVER_ERROR"; String codeName = "INTERNAL_SERVER_ERROR";
ErrorLogEntity errorLog = ErrorLogEntity errorLog =
saveErrorLogData( saveErrorLogData(
request, request,
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
HttpStatus.valueOf(codeName), HttpStatus.valueOf(codeName),
ErrorLogDto.LogErrorLevel.CRITICAL, ErrorLogDto.LogErrorLevel.CRITICAL,
e.getStackTrace()); e.getStackTrace());
return ApiResponseDto.createException( return ApiResponseDto.createException(
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
ApiResponseCode.getMessage(codeName), ApiResponseCode.getMessage(codeName),
HttpStatus.valueOf(codeName), HttpStatus.valueOf(codeName),
errorLog.getId()); errorLog.getId());
} }
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@@ -365,36 +365,36 @@ public class GlobalExceptionHandler {
String codeName = "INTERNAL_SERVER_ERROR"; String codeName = "INTERNAL_SERVER_ERROR";
ErrorLogEntity errorLog = ErrorLogEntity errorLog =
saveErrorLogData( saveErrorLogData(
request, request,
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
HttpStatus.valueOf(codeName), HttpStatus.valueOf(codeName),
ErrorLogDto.LogErrorLevel.CRITICAL, ErrorLogDto.LogErrorLevel.CRITICAL,
e.getStackTrace()); e.getStackTrace());
return ApiResponseDto.createException( return ApiResponseDto.createException(
ApiResponseCode.getCode(codeName), ApiResponseCode.getCode(codeName),
ApiResponseCode.getMessage(codeName), ApiResponseCode.getMessage(codeName),
HttpStatus.valueOf(codeName), HttpStatus.valueOf(codeName),
errorLog.getId()); errorLog.getId());
} }
/** /**
* 에러 로그 테이블 저장 로직 * 에러 로그 테이블 저장 로직
* *
* @param request : request * @param request : request
* @param errorCode : 정의된 enum errorCode * @param errorCode : 정의된 enum errorCode
* @param httpStatus : HttpStatus 값 * @param httpStatus : HttpStatus 값
* @param logErrorLevel : WARNING, ERROR, CRITICAL * @param logErrorLevel : WARNING, ERROR, CRITICAL
* @param stackTrace : 에러 내용 * @param stackTrace : 에러 내용
* @return : insert하고 결과로 받은 Entity * @return : insert하고 결과로 받은 Entity
*/ */
private ErrorLogEntity saveErrorLogData( private ErrorLogEntity saveErrorLogData(
HttpServletRequest request, HttpServletRequest request,
ApiResponseCode errorCode, ApiResponseCode errorCode,
HttpStatus httpStatus, HttpStatus httpStatus,
ErrorLogDto.LogErrorLevel logErrorLevel, ErrorLogDto.LogErrorLevel logErrorLevel,
StackTraceElement[] stackTrace) { StackTraceElement[] stackTrace) {
Long userid = null; Long userid = null;
@@ -408,35 +408,35 @@ public class GlobalExceptionHandler {
* 만든 CustomUserDetails 타입인가? 체크 * 만든 CustomUserDetails 타입인가? 체크
*/ */
if (request.getUserPrincipal() instanceof UsernamePasswordAuthenticationToken auth if (request.getUserPrincipal() instanceof UsernamePasswordAuthenticationToken auth
&& auth.getPrincipal() instanceof CustomUserDetails customUserDetails) { && auth.getPrincipal() instanceof CustomUserDetails customUserDetails) {
// audit 에는 long 타입 user_id가 들어가지만 토큰 sub은 uuid여서 user_id 가져오기 // audit 에는 long 타입 user_id가 들어가지만 토큰 sub은 uuid여서 user_id 가져오기
userid = customUserDetails.getMember().getId(); userid = customUserDetails.getMember().getId();
} }
String stackTraceStr = String stackTraceStr =
Arrays.stream(stackTrace) Arrays.stream(stackTrace)
.map(StackTraceElement::toString) .map(StackTraceElement::toString)
.collect(Collectors.joining("\n")) .collect(Collectors.joining("\n"))
.substring(0, Math.min(stackTrace.length, 255)); .substring(0, Math.min(stackTrace.length, 255));
ErrorLogEntity errorLogEntity = ErrorLogEntity errorLogEntity =
new ErrorLogEntity( new ErrorLogEntity(
request.getRequestURI(), request.getRequestURI(),
ApiLogFunction.getEventType(request), ApiLogFunction.getEventType(request),
logErrorLevel, logErrorLevel,
String.valueOf(httpStatus.value()), String.valueOf(httpStatus.value()),
errorCode.getText(), errorCode.getText(),
stackTraceStr, stackTraceStr,
userid, userid,
ZonedDateTime.now()); ZonedDateTime.now());
return errorLogRepository.save(errorLogEntity); return errorLogRepository.save(errorLogEntity);
} }
@ExceptionHandler(CustomApiException.class) @ExceptionHandler(CustomApiException.class)
public ResponseEntity<ApiResponseDto<String>> handleCustomApiException( public ResponseEntity<ApiResponseDto<String>> handleCustomApiException(
CustomApiException e, HttpServletRequest request) { CustomApiException e, HttpServletRequest request) {
log.warn("[CustomApiException] resource : {}", e.getMessage()); log.warn("[CustomApiException] resource : {}", e.getMessage());
String codeName = e.getCodeName(); String codeName = e.getCodeName();
@@ -446,11 +446,11 @@ public class GlobalExceptionHandler {
ApiResponseCode apiCode = ApiResponseCode.getCode(codeName); ApiResponseCode apiCode = ApiResponseCode.getCode(codeName);
ErrorLogEntity errorLog = ErrorLogEntity errorLog =
saveErrorLogData( saveErrorLogData(
request, apiCode, status, ErrorLogDto.LogErrorLevel.WARNING, e.getStackTrace()); request, apiCode, status, ErrorLogDto.LogErrorLevel.WARNING, e.getStackTrace());
ApiResponseDto<String> body = ApiResponseDto<String> body =
ApiResponseDto.createException(apiCode, message, status, errorLog.getId()); ApiResponseDto.createException(apiCode, message, status, errorLog.getId());
return new ResponseEntity<>(body, status); return new ResponseEntity<>(body, status);
} }

View File

@@ -5,17 +5,4 @@ public interface EnumType {
String getId(); String getId();
String getText(); String getText();
// code로 text
static <E extends Enum<E> & EnumType> E fromId(Class<E> enumClass, String id) {
if (id == null) {
return null;
}
for (E e : enumClass.getEnumConstants()) {
if (id.equalsIgnoreCase(e.getId())) {
return e;
}
}
return null; // 못 찾으면 null
}
} }

View File

@@ -57,11 +57,44 @@ public class MapSheetMngApiController {
return ApiResponseDto.ok(mapSheetMngService.findMapSheetMngList(searchReq)); return ApiResponseDto.ok(mapSheetMngService.findMapSheetMngList(searchReq));
} }
@Operation(summary = "영상관리 > 데이터 등록", description = "영상관리 > 데이터 등록")
@ApiResponses(
value = {
@ApiResponse(
responseCode = "201",
description = "데이터 등록 성공",
content =
@Content(
mediaType = "application/json",
schema = @Schema(implementation = Long.class))),
@ApiResponse(responseCode = "400", description = "잘못된 요청 데이터", content = @Content),
@ApiResponse(responseCode = "404", description = "데이터를 찾을 수 없음", content = @Content),
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
})
@PutMapping("/mng-data-save")
public ApiResponseDto<MapSheetMngDto.DmlReturn> mngDataSave(
@RequestBody @Valid MapSheetMngDto.AddReq AddReq) {
return ApiResponseDto.ok(mapSheetMngService.mngDataSave(AddReq));
}
/** /**
* @param hstUidList * @param hstUidList
* @return * @return
*/ */
@Operation(summary = "오류데이터 팝업 > 업로드 처리", description = "오류데이터 팝업 > 업로드 처리") @Operation(summary = "오류데이터 팝업 > 업로드 처리", description = "오류데이터 팝업 > 업로드 처리")
@ApiResponses(
value = {
@ApiResponse(
responseCode = "201",
description = "공통코드 저장 성공",
content =
@Content(
mediaType = "application/json",
schema = @Schema(implementation = Long.class))),
@ApiResponse(responseCode = "400", description = "잘못된 요청 데이터", content = @Content),
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
})
@PutMapping("/upload-process") @PutMapping("/upload-process")
public ApiResponseDto<MapSheetMngDto.DmlReturn> uploadProcess( public ApiResponseDto<MapSheetMngDto.DmlReturn> uploadProcess(
@RequestBody @Valid List<Long> hstUidList) { @RequestBody @Valid List<Long> hstUidList) {

View File

@@ -5,10 +5,8 @@ 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.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.FoldersDto;
import com.kamco.cd.kamcoback.mapsheet.dto.FileDto.SrchFilesDepthDto;
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.ImageryDto;
import com.kamco.cd.kamcoback.mapsheet.service.MapSheetMngFileCheckerService; import com.kamco.cd.kamcoback.mapsheet.service.MapSheetMngFileCheckerService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Content;
@@ -16,7 +14,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@@ -32,7 +29,7 @@ public class MapSheetMngFileCheckerApiController {
private final CommonCodeService commonCodeService; private final CommonCodeService commonCodeService;
private final MapSheetMngFileCheckerService mapSheetMngFileCheckerService; private final MapSheetMngFileCheckerService mapSheetMngFileCheckerService;
@Operation(summary = "폴더 조회", description = "폴더 조회") @Operation(summary = "폴더 조회", description = "폴더 조회 (ROOT:/app/original-images 이하로 경로입력)")
@ApiResponses( @ApiResponses(
value = { value = {
@ApiResponse( @ApiResponse(
@@ -47,6 +44,7 @@ public class MapSheetMngFileCheckerApiController {
}) })
@PostMapping("/folder-list") @PostMapping("/folder-list")
public ApiResponseDto<FoldersDto> getDir(@RequestBody SrchFoldersDto srchDto) { public ApiResponseDto<FoldersDto> getDir(@RequestBody SrchFoldersDto srchDto) {
return ApiResponseDto.createOK(mapSheetMngFileCheckerService.getFolderAll(srchDto)); return ApiResponseDto.createOK(mapSheetMngFileCheckerService.getFolderAll(srchDto));
} }
@@ -69,6 +67,7 @@ public class MapSheetMngFileCheckerApiController {
return ApiResponseDto.createOK(mapSheetMngFileCheckerService.getFilesAll(srchDto)); return ApiResponseDto.createOK(mapSheetMngFileCheckerService.getFilesAll(srchDto));
} }
/*
@Operation(summary = "지정폴더(하위폴더포함) 파일목록 조회", description = "지정폴더(하위폴더포함) 파일목록 조회") @Operation(summary = "지정폴더(하위폴더포함) 파일목록 조회", description = "지정폴더(하위폴더포함) 파일목록 조회")
@ApiResponses( @ApiResponses(
value = { value = {
@@ -106,4 +105,7 @@ public class MapSheetMngFileCheckerApiController {
@RequestBody @Valid ImageryDto.searchReq searchReq) { @RequestBody @Valid ImageryDto.searchReq searchReq) {
return ApiResponseDto.ok(mapSheetMngFileCheckerService.syncProcess(searchReq)); return ApiResponseDto.ok(mapSheetMngFileCheckerService.syncProcess(searchReq));
} }
*/
} }

View File

@@ -15,7 +15,7 @@ public class FileDto {
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public static class SrchFoldersDto { public static class SrchFoldersDto {
@Schema(description = "디렉토리경로", example = "D:\\kamco") @Schema(description = "디렉토리경로(ROOT:/app/original-images)", example = "")
@NotNull @NotNull
private String dirPath; private String dirPath;
} }

View File

@@ -1,7 +1,9 @@
package com.kamco.cd.kamcoback.mapsheet.dto; package com.kamco.cd.kamcoback.mapsheet.dto;
import com.kamco.cd.kamcoback.common.utils.interfaces.JsonFormatDttm;
import com.kamco.cd.kamcoback.config.enums.EnumType; import com.kamco.cd.kamcoback.config.enums.EnumType;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import java.time.ZonedDateTime;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@@ -62,6 +64,19 @@ public class MapSheetMngDto {
private DataState dataState; private DataState dataState;
} }
@Schema(name = "MngAddReq", description = "영상관리 생성 요청")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public static class AddReq {
@Schema(description = "관리년도", example = "2022")
private int mngYyyy;
@Schema(description = "선택폴더경로", example = "D:\\app\\original-images\\2022")
private String mngPath;
}
@Schema(name = "MngDto", description = "영상관리 검색 리턴") @Schema(name = "MngDto", description = "영상관리 검색 리턴")
@Getter @Getter
@Setter @Setter
@@ -72,15 +87,15 @@ public class MapSheetMngDto {
private int mngYyyy; private int mngYyyy;
private String mngState; private String mngState;
private String syncState; private String syncState;
private String mngStateDttm; private String syncCheckState;
private String syncStateDttm; private Long syncTotCnt;
// private int sheetCnt; private Long syncStateDoneCnt;
// private int exceptCnt; private Long syncCheckStateDoneCnt;
private String mngPath; private Long syncNotFileCnt;
private String createdDttm; private Long syncTypeErrorCnt;
private Long createdUid; private Long syncSizeErrorCnt;
private String updatedDttm; @JsonFormatDttm private ZonedDateTime rgstStrtDttm;
private Long updatedUid; @JsonFormatDttm private ZonedDateTime rgstEndDttm;
} }
@Schema(name = "DmlReturn", description = "영상관리 DML 수행 후 리턴") @Schema(name = "DmlReturn", description = "영상관리 DML 수행 후 리턴")

View File

@@ -3,6 +3,7 @@ package com.kamco.cd.kamcoback.mapsheet.service;
import static java.lang.String.CASE_INSENSITIVE_ORDER; import static java.lang.String.CASE_INSENSITIVE_ORDER;
import com.kamco.cd.kamcoback.common.utils.NameValidator; import com.kamco.cd.kamcoback.common.utils.NameValidator;
import com.kamco.cd.kamcoback.config.FileConfig;
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;
@@ -38,11 +39,15 @@ import org.springframework.transaction.annotation.Transactional;
public class MapSheetMngFileCheckerService { public class MapSheetMngFileCheckerService {
private final MapSheetMngFileCheckerCoreService mapSheetMngFileCheckerCoreService; private final MapSheetMngFileCheckerCoreService mapSheetMngFileCheckerCoreService;
private final FileConfig fileConfig;
public FoldersDto getFolderAll(SrchFoldersDto srchDto) { public FoldersDto getFolderAll(SrchFoldersDto srchDto) {
Path startPath = Paths.get(srchDto.getDirPath()); Path startPath = Paths.get(fileConfig.getRootSyncDir() + srchDto.getDirPath());
String dirPath = srchDto.getDirPath(); String dirPath = fileConfig.getRootSyncDir() + srchDto.getDirPath();
// Path startPath = Paths.get(fileConfig.getRootSyncDir()+srchDto.getDirPath());
// String dirPath = fileConfig.getRootSyncDir()+srchDto.getDirPath();
int maxDepth = 1; int maxDepth = 1;

View File

@@ -222,6 +222,10 @@ public class MapSheetMngService {
return mapSheetMngCoreService.findMapSheetMngList(searchReq); return mapSheetMngCoreService.findMapSheetMngList(searchReq);
} }
public MapSheetMngDto.DmlReturn mngDataSave(@Valid MapSheetMngDto.AddReq AddReq) {
return mapSheetMngCoreService.mngDataSave(AddReq);
}
public MapSheetMngDto.DmlReturn uploadProcess(@Valid List<Long> hstUidList) { public MapSheetMngDto.DmlReturn uploadProcess(@Valid List<Long> hstUidList) {
return mapSheetMngCoreService.uploadProcess(hstUidList); return mapSheetMngCoreService.uploadProcess(hstUidList);
} }

View File

@@ -2,8 +2,8 @@ package com.kamco.cd.kamcoback.members.dto;
import com.kamco.cd.kamcoback.common.enums.RoleType; import com.kamco.cd.kamcoback.common.enums.RoleType;
import com.kamco.cd.kamcoback.common.enums.StatusType; import com.kamco.cd.kamcoback.common.enums.StatusType;
import com.kamco.cd.kamcoback.common.utils.Enums;
import com.kamco.cd.kamcoback.common.utils.interfaces.JsonFormatDttm; import com.kamco.cd.kamcoback.common.utils.interfaces.JsonFormatDttm;
import com.kamco.cd.kamcoback.config.enums.EnumType;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
@@ -32,24 +32,28 @@ public class MembersDto {
private String tempPassword; private String tempPassword;
private String status; private String status;
private String statusName; private String statusName;
@JsonFormatDttm private ZonedDateTime createdDttm; @JsonFormatDttm
@JsonFormatDttm private ZonedDateTime updatedDttm; private ZonedDateTime createdDttm;
@JsonFormatDttm private ZonedDateTime firstLoginDttm; @JsonFormatDttm
@JsonFormatDttm private ZonedDateTime lastLoginDttm; private ZonedDateTime updatedDttm;
@JsonFormatDttm
private ZonedDateTime firstLoginDttm;
@JsonFormatDttm
private ZonedDateTime lastLoginDttm;
public Basic( public Basic(
Long id, Long id,
UUID uuid, UUID uuid,
String userRole, String userRole,
String name, String name,
String userId, String userId,
String employeeNo, String employeeNo,
String tempPassword, String tempPassword,
String status, String status,
ZonedDateTime createdDttm, ZonedDateTime createdDttm,
ZonedDateTime updatedDttm, ZonedDateTime updatedDttm,
ZonedDateTime firstLoginDttm, ZonedDateTime firstLoginDttm,
ZonedDateTime lastLoginDttm) { ZonedDateTime lastLoginDttm) {
this.id = id; this.id = id;
this.uuid = uuid; this.uuid = uuid;
this.userRole = userRole; this.userRole = userRole;
@@ -67,12 +71,12 @@ public class MembersDto {
} }
private String getUserRoleName(String roleId) { private String getUserRoleName(String roleId) {
RoleType type = EnumType.fromId(RoleType.class, roleId); RoleType type = Enums.fromId(RoleType.class, roleId);
return type.getText(); return type.getText();
} }
private String getStatusName(String status) { private String getStatusName(String status) {
StatusType type = EnumType.fromId(StatusType.class, status); StatusType type = Enums.fromId(StatusType.class, status);
return type.getText(); return type.getText();
} }
} }
@@ -84,8 +88,8 @@ public class MembersDto {
public static class SearchReq { public static class SearchReq {
@Schema( @Schema(
description = "전체, 관리자(ROLE_ADMIN), 라벨러(ROLE_LABELER), 검수자(ROLE_REVIEWER)", description = "전체, 관리자(ROLE_ADMIN), 라벨러(ROLE_LABELER), 검수자(ROLE_REVIEWER)",
example = "") example = "")
private String userRole; private String userRole;
@Schema(description = "키워드", example = "홍길동") @Schema(description = "키워드", example = "홍길동")
@@ -129,7 +133,7 @@ public class MembersDto {
private String employeeNo; private String employeeNo;
public AddReq( public AddReq(
String userRole, String name, String userId, String tempPassword, String employeeNo) { String userRole, String name, String userId, String tempPassword, String employeeNo) {
this.userRole = userRole; this.userRole = userRole;
this.name = name; this.name = name;
this.userId = userId; this.userId = userId;

View File

@@ -1,6 +1,7 @@
package com.kamco.cd.kamcoback.postgres.core; package com.kamco.cd.kamcoback.postgres.core;
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto; import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngEntity;
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity; import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity;
import com.kamco.cd.kamcoback.postgres.repository.mapsheet.MapSheetMngRepository; import com.kamco.cd.kamcoback.postgres.repository.mapsheet.MapSheetMngRepository;
import jakarta.persistence.EntityNotFoundException; import jakarta.persistence.EntityNotFoundException;
@@ -67,9 +68,11 @@ public class MapSheetMngCoreService {
count += 1; count += 1;
} }
/*
MapSheetMngDto.DataState dataState = MapSheetMngDto.DataState dataState =
flag ? MapSheetMngDto.DataState.SUCCESS : MapSheetMngDto.DataState.FAIL; flag ? MapSheetMngDto.DataState.SUCCESS : MapSheetMngDto.DataState.FAIL;
entity.get().updateDataState(dataState); entity.get().updateDataState(dataState);
*/
} }
} }
return new MapSheetMngDto.DmlReturn("success", count + "개 업로드 성공하였습니다."); return new MapSheetMngDto.DmlReturn("success", count + "개 업로드 성공하였습니다.");
@@ -84,7 +87,7 @@ public class MapSheetMngCoreService {
.findMapSheetMngHstInfo(hstUid) .findMapSheetMngHstInfo(hstUid)
.orElseThrow(EntityNotFoundException::new)); .orElseThrow(EntityNotFoundException::new));
entity.get().updateUseInference(true); // entity.get().updateUseInference(true);
} }
} }
return new MapSheetMngDto.DmlReturn("success", hstUidList.size() + "개 추론제외 업데이트 하였습니다."); return new MapSheetMngDto.DmlReturn("success", hstUidList.size() + "개 추론제외 업데이트 하였습니다.");
@@ -122,4 +125,15 @@ public class MapSheetMngCoreService {
throw new RuntimeException("File search error", e); throw new RuntimeException("File search error", e);
} }
} }
public MapSheetMngDto.DmlReturn mngDataSave(@Valid MapSheetMngDto.AddReq addReq) {
MapSheetMngEntity entity = new MapSheetMngEntity();
entity.setMngYyyy(addReq.getMngYyyy());
entity.setMngPath(addReq.getMngPath());
MapSheetMngEntity saved = mapSheetMngRepository.save(entity);
return new MapSheetMngDto.DmlReturn("success", saved.getMngYyyy().toString());
}
} }

View File

@@ -5,7 +5,7 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Id; import jakarta.persistence.Id;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import java.time.OffsetDateTime; import java.time.ZonedDateTime;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.hibernate.annotations.ColumnDefault; import org.hibernate.annotations.ColumnDefault;
@@ -18,30 +18,32 @@ public class MapSheetMngEntity {
@Id @Id
@Column(name = "mng_yyyy", nullable = false) @Column(name = "mng_yyyy", nullable = false)
private Integer id; private Integer mngYyyy;
@Size(max = 20) @Size(max = 20)
@ColumnDefault("'NOTYET'")
@Column(name = "mng_state", length = 20) @Column(name = "mng_state", length = 20)
private String mngState; private String mngState = "NOTYET";
@Size(max = 20) @Size(max = 20)
@ColumnDefault("'NOTYET'")
@Column(name = "sync_state", length = 20) @Column(name = "sync_state", length = 20)
private String syncState; private String syncState = "NOTYET";
@Column(name = "mng_state_dttm") @Column(name = "mng_state_dttm")
private OffsetDateTime mngStateDttm; private ZonedDateTime mngStateDttm = ZonedDateTime.now();
@Column(name = "sync_state_dttm") @Column(name = "sync_state_dttm")
private OffsetDateTime syncStateDttm; private ZonedDateTime syncStateDttm = ZonedDateTime.now();
@Column(name = "created_dttm") @Column(name = "created_dttm")
private OffsetDateTime createdDttm; private ZonedDateTime createdDttm = ZonedDateTime.now();
@Column(name = "created_uid") @Column(name = "created_uid")
private Long createdUid; private Long createdUid;
@Column(name = "updated_dttm") @Column(name = "updated_dttm")
private OffsetDateTime updatedDttm; private ZonedDateTime updatedDttm = ZonedDateTime.now();
@Column(name = "updated_uid") @Column(name = "updated_uid")
private Long updatedUid; private Long updatedUid;
@@ -50,4 +52,21 @@ public class MapSheetMngEntity {
@ColumnDefault("'NULL::character varying'") @ColumnDefault("'NULL::character varying'")
@Column(name = "mng_path") @Column(name = "mng_path")
private String mngPath; private String mngPath;
@Size(max = 20)
@ColumnDefault("'NOTYET'")
@Column(name = "sync_check_state", length = 20)
private String syncCheckState = "NOTYET";
@Column(name = "sync_strt_dttm")
private ZonedDateTime syncStrtDttm;
@Column(name = "sync_end_dttm")
private ZonedDateTime syncEndDttm;
@Column(name = "sync_check_strt_dttm")
private ZonedDateTime syncCheckStrtDttm;
@Column(name = "sync_check_end_dttm")
private ZonedDateTime syncCheckEndDttm;
} }

View File

@@ -1,8 +1,8 @@
package com.kamco.cd.kamcoback.postgres.entity; package com.kamco.cd.kamcoback.postgres.entity;
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
import com.kamco.cd.kamcoback.postgres.CommonDateEntity; import com.kamco.cd.kamcoback.postgres.CommonDateEntity;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.Size;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@@ -35,9 +35,8 @@ public class MapSheetMngHstEntity extends CommonDateEntity {
@Column(name = "scale_ratio") @Column(name = "scale_ratio")
private Integer scaleRatio; private Integer scaleRatio;
@Column(name = "data_state") @Column(name = "data_state", length = 20)
@Enumerated(EnumType.STRING) private String dataState;
private MapSheetMngDto.DataState dataState;
@Column(name = "data_state_dttm") @Column(name = "data_state_dttm")
private ZonedDateTime dataStateDttm; private ZonedDateTime dataStateDttm;
@@ -60,13 +59,23 @@ public class MapSheetMngHstEntity extends CommonDateEntity {
@Column(name = "updated_uid") @Column(name = "updated_uid")
private Long updatedUid; private Long updatedUid;
public void updateDataState(MapSheetMngDto.DataState dataState) { @Size(max = 20)
this.dataState = dataState; @Column(name = "sync_state", length = 20)
this.dataStateDttm = ZonedDateTime.now(); private String syncState;
}
public void updateUseInference(Boolean useInference) { @Size(max = 20)
this.useInference = useInference; @Column(name = "sync_check_state", length = 20)
this.useInferenceDttm = ZonedDateTime.now(); private String syncCheckState;
}
@Column(name = "sync_strt_dttm")
private ZonedDateTime syncStrtDttm;
@Column(name = "sync_end_dttm")
private ZonedDateTime syncEndDttm;
@Column(name = "sync_check_strt_dttm")
private ZonedDateTime syncCheckStrtDttm;
@Column(name = "sync_check_end_dttm")
private ZonedDateTime syncCheckEndDttm;
} }

View File

@@ -7,6 +7,7 @@ import java.util.Optional;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
public interface MapSheetMngRepositoryCustom { public interface MapSheetMngRepositoryCustom {
Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList( Page<MapSheetMngDto.ErrorDataDto> findMapSheetErrorList(
MapSheetMngDto.@Valid searchReq searchReq); MapSheetMngDto.@Valid searchReq searchReq);

View File

@@ -10,6 +10,7 @@ import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity;
import com.querydsl.core.BooleanBuilder; import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.types.Projections; import com.querydsl.core.types.Projections;
import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.CaseBuilder;
import com.querydsl.core.types.dsl.Expressions; import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.core.types.dsl.NumberExpression; import com.querydsl.core.types.dsl.NumberExpression;
import com.querydsl.core.types.dsl.StringExpression; import com.querydsl.core.types.dsl.StringExpression;
@@ -64,7 +65,7 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
.on(mapInkx5kEntity.fidK50.eq(mapInkx50kEntity.fid.longValue())) .on(mapInkx5kEntity.fidK50.eq(mapInkx50kEntity.fid.longValue()))
.where( .where(
mapSheetMngHstEntity.mngYyyy.eq(searchReq.getMngYyyy()), mapSheetMngHstEntity.mngYyyy.eq(searchReq.getMngYyyy()),
mapSheetMngHstEntity.dataState.eq(MapSheetMngDto.DataState.FAIL), // 오류만 검색 // mapSheetMngHstEntity.dataState.eq(MapSheetMngDto.DataState.FAIL), // 오류만 검색
mapSheetErrorSearchValue(searchReq)) mapSheetErrorSearchValue(searchReq))
.offset(pageable.getOffset()) .offset(pageable.getOffset())
.limit(pageable.getPageSize()) .limit(pageable.getPageSize())
@@ -81,7 +82,7 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
.on(mapInkx5kEntity.fidK50.eq(mapInkx50kEntity.fid.longValue())) .on(mapInkx5kEntity.fidK50.eq(mapInkx50kEntity.fid.longValue()))
.where( .where(
mapSheetMngHstEntity.mngYyyy.eq(searchReq.getMngYyyy()), mapSheetMngHstEntity.mngYyyy.eq(searchReq.getMngYyyy()),
mapSheetMngHstEntity.dataState.eq(MapSheetMngDto.DataState.FAIL), // 오류만 검색 // mapSheetMngHstEntity.dataState.eq(MapSheetMngDto.DataState.FAIL), // 오류만 검색
mapSheetErrorSearchValue(searchReq)) mapSheetErrorSearchValue(searchReq))
.fetchOne(); .fetchOne();
@@ -96,9 +97,30 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
BooleanBuilder whereBuilder = new BooleanBuilder(); BooleanBuilder whereBuilder = new BooleanBuilder();
if (searchReq.getMngYyyy() != null) { if (searchReq.getMngYyyy() != null) {
whereBuilder.and(mapSheetMngEntity.id.eq(searchReq.getMngYyyy())); whereBuilder.and(mapSheetMngEntity.mngYyyy.eq(searchReq.getMngYyyy()));
} }
/*
QMapSheetMngEntity m = mapSheetMngEntity;
QMapSheetMngHstEntity h = mapSheetMngHstEntity;
List<MapSheetSummaryDto> summaryContent =
queryFactory
.select(
Projections.constructor(
MapSheetSummaryDto.class,
mapSheetMngHstEntity.mngYyyy,
mapSheetMngHstEntity.mngYyyy.count().as("syncTotCnt"),
new CaseBuilder()
.when(mapSheetMngHstEntity.syncState.eq("DONE")).then(1L).otherwise(0L)
.sum().as("syncStateDoneCnt")
))
.from(mapSheetMngHstEntity)
.groupBy(mapSheetMngHstEntity.mngYyyy) // mng_yyyy 별로 그룹핑
.fetch();
*/
List<MapSheetMngDto.MngDto> foundContent = List<MapSheetMngDto.MngDto> foundContent =
queryFactory queryFactory
.select( .select(
@@ -108,30 +130,52 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
Integer.class, Integer.class,
"row_number() over(order by {0} desc)", "row_number() over(order by {0} desc)",
mapSheetMngEntity.createdDttm), mapSheetMngEntity.createdDttm),
mapSheetMngEntity.id, mapSheetMngEntity.mngYyyy,
mapSheetMngEntity.mngState, mapSheetMngEntity.mngState,
mapSheetMngEntity.syncState, mapSheetMngEntity.syncState,
Expressions.stringTemplate( mapSheetMngEntity.syncCheckState,
"to_char({0}, 'YYYY-MM-DD HH24:MI:SS')", mapSheetMngEntity.mngStateDttm), mapSheetMngHstEntity.count(),
Expressions.stringTemplate( new CaseBuilder()
"to_char({0}, 'YYYY-MM-DD HH24:MI:SS')", mapSheetMngEntity.syncStateDttm), .when(mapSheetMngHstEntity.syncState.eq("DONE"))
mapSheetMngEntity.mngPath, .then(1L)
Expressions.stringTemplate( .otherwise(0L)
"to_char({0}, 'YYYY-MM-DD HH24:MI:SS')", mapSheetMngEntity.createdDttm), .sum()
mapSheetMngEntity.createdUid, .as("syncStateDoneCnt"),
Expressions.stringTemplate( new CaseBuilder()
"to_char({0}, 'YYYY-MM-DD HH24:MI:SS')", mapSheetMngEntity.updatedDttm), .when(mapSheetMngHstEntity.syncCheckState.eq("DONE"))
mapSheetMngEntity.updatedUid)) .then(1L)
.otherwise(0L)
.sum(),
new CaseBuilder()
.when(mapSheetMngHstEntity.dataState.eq("NOT"))
.then(1L)
.otherwise(0L)
.sum(),
new CaseBuilder()
.when(mapSheetMngHstEntity.dataState.eq("TYPEERROR"))
.then(1L)
.otherwise(0L)
.sum(),
new CaseBuilder()
.when(mapSheetMngHstEntity.dataState.eq("SIZEERROR"))
.then(1L)
.otherwise(0L)
.sum(),
mapSheetMngHstEntity.syncStrtDttm.min(),
mapSheetMngHstEntity.syncCheckEndDttm.max()))
.from(mapSheetMngEntity) .from(mapSheetMngEntity)
.leftJoin(mapSheetMngHstEntity)
.on(mapSheetMngEntity.mngYyyy.eq(mapSheetMngHstEntity.mngYyyy))
.where(whereBuilder) .where(whereBuilder)
.offset(pageable.getOffset()) .offset(pageable.getOffset())
.limit(pageable.getPageSize()) .limit(pageable.getPageSize())
.orderBy(mapSheetMngEntity.createdDttm.desc()) .orderBy(mapSheetMngEntity.createdDttm.desc())
.groupBy(mapSheetMngEntity.mngYyyy)
.fetch(); .fetch();
Long countQuery = Long countQuery =
queryFactory queryFactory
.select(mapSheetMngEntity.id.count()) .select(mapSheetMngEntity.mngYyyy.count())
.from(mapSheetMngEntity) .from(mapSheetMngEntity)
.where(whereBuilder) .where(whereBuilder)
.fetchOne(); .fetchOne();