Merge remote-tracking branch 'origin/feat/dev_251201' into feat/dev_251201
# Conflicts: # src/main/java/com/kamco/cd/kamcoback/mapsheet/service/MapSheetMngService.java
This commit is contained in:
@@ -50,6 +50,7 @@ public class GlobalExceptionHandler {
|
||||
public ApiResponseDto<String> handleDuplicateFileException(
|
||||
DuplicateFileException e, HttpServletRequest request) {
|
||||
log.warn("[DuplicateFileException] resource :{} ", e.getMessage());
|
||||
this.errorLog(request, e);
|
||||
ApiResponseCode code = ApiResponseCode.CONFLICT;
|
||||
ErrorLogEntity errorLog =
|
||||
saveErrorLogData(
|
||||
@@ -68,6 +69,7 @@ public class GlobalExceptionHandler {
|
||||
public ApiResponseDto<String> handleValidationException(
|
||||
ValidationException e, HttpServletRequest request) {
|
||||
log.warn("[ValidationException] resource :{} ", e.getMessage());
|
||||
this.errorLog(request, e);
|
||||
ApiResponseCode code = ApiResponseCode.UNPROCESSABLE_ENTITY;
|
||||
ErrorLogEntity errorLog =
|
||||
saveErrorLogData(
|
||||
@@ -86,6 +88,7 @@ public class GlobalExceptionHandler {
|
||||
public ApiResponseDto<String> handleIllegalArgumentException(
|
||||
IllegalArgumentException e, HttpServletRequest request) {
|
||||
log.warn("[IllegalArgumentException] resource :{} ", e.getMessage());
|
||||
this.errorLog(request, e);
|
||||
ApiResponseCode code = ApiResponseCode.BAD_REQUEST;
|
||||
ErrorLogEntity errorLog =
|
||||
saveErrorLogData(
|
||||
@@ -104,6 +107,7 @@ public class GlobalExceptionHandler {
|
||||
public ApiResponseDto<String> handlerEntityNotFoundException(
|
||||
EntityNotFoundException e, HttpServletRequest request) {
|
||||
log.warn("[EntityNotFoundException] resource :{} ", e.getMessage());
|
||||
this.errorLog(request, e);
|
||||
String codeName = "NOT_FOUND_DATA";
|
||||
ErrorLogEntity errorLog =
|
||||
saveErrorLogData(
|
||||
@@ -125,6 +129,7 @@ public class GlobalExceptionHandler {
|
||||
public ApiResponseDto<String> handleUnreadable(
|
||||
HttpMessageNotReadableException e, HttpServletRequest request) {
|
||||
log.warn("[HttpMessageNotReadableException] resource :{} ", e.getMessage());
|
||||
this.errorLog(request, e);
|
||||
String codeName = "BAD_REQUEST";
|
||||
ErrorLogEntity errorLog =
|
||||
saveErrorLogData(
|
||||
@@ -146,6 +151,7 @@ public class GlobalExceptionHandler {
|
||||
public ApiResponseDto<String> handlerNoSuchElementException(
|
||||
NoSuchElementException e, HttpServletRequest request) {
|
||||
log.warn("[NoSuchElementException] resource :{} ", e.getMessage());
|
||||
this.errorLog(request, e);
|
||||
String codeName = "NOT_FOUND_DATA";
|
||||
ErrorLogEntity errorLog =
|
||||
saveErrorLogData(
|
||||
@@ -167,6 +173,7 @@ public class GlobalExceptionHandler {
|
||||
public ApiResponseDto<String> handlerDataIntegrityViolationException(
|
||||
DataIntegrityViolationException e, HttpServletRequest request) {
|
||||
log.warn("[DataIntegrityViolationException] resource :{} ", e.getMessage());
|
||||
this.errorLog(request, e);
|
||||
String codeName = "DATA_INTEGRITY_ERROR";
|
||||
ErrorLogEntity errorLog =
|
||||
saveErrorLogData(
|
||||
@@ -188,6 +195,7 @@ public class GlobalExceptionHandler {
|
||||
public ApiResponseDto<String> handlerMethodArgumentNotValidException(
|
||||
MethodArgumentNotValidException e, HttpServletRequest request) {
|
||||
log.warn("[MethodArgumentNotValidException] resource :{} ", e.getMessage());
|
||||
this.errorLog(request, e);
|
||||
String codeName = "BAD_REQUEST";
|
||||
ErrorLogEntity errorLog =
|
||||
saveErrorLogData(
|
||||
@@ -209,6 +217,7 @@ public class GlobalExceptionHandler {
|
||||
public ApiResponseDto<String> handlerAccessDeniedException(
|
||||
AccessDeniedException e, HttpServletRequest request) {
|
||||
log.warn("[AccessDeniedException] resource :{} ", e.getMessage());
|
||||
this.errorLog(request, e);
|
||||
String codeName = "FORBIDDEN";
|
||||
ErrorLogEntity errorLog =
|
||||
saveErrorLogData(
|
||||
@@ -230,6 +239,7 @@ public class GlobalExceptionHandler {
|
||||
public ApiResponseDto<String> handlerHttpServerErrorException(
|
||||
HttpServerErrorException e, HttpServletRequest request) {
|
||||
log.warn("[HttpServerErrorException] resource :{} ", e.getMessage());
|
||||
this.errorLog(request, e);
|
||||
String codeName = "BAD_GATEWAY";
|
||||
ErrorLogEntity errorLog =
|
||||
saveErrorLogData(
|
||||
@@ -251,7 +261,7 @@ public class GlobalExceptionHandler {
|
||||
public ApiResponseDto<String> handlerIllegalStateException(
|
||||
IllegalStateException e, HttpServletRequest request) {
|
||||
log.warn("[IllegalStateException] resource :{} ", e.getMessage());
|
||||
|
||||
this.errorLog(request, e);
|
||||
String codeName = "UNPROCESSABLE_ENTITY";
|
||||
ErrorLogEntity errorLog =
|
||||
saveErrorLogData(
|
||||
@@ -273,7 +283,7 @@ public class GlobalExceptionHandler {
|
||||
public ApiResponseDto<String> handlerDuplicateMemberException(
|
||||
MemberException.DuplicateMemberException e, HttpServletRequest request) {
|
||||
log.warn("[DuplicateMemberException] resource :{} ", e.getMessage());
|
||||
|
||||
this.errorLog(request, e);
|
||||
String codeName = "";
|
||||
|
||||
switch (e.getField()) {
|
||||
@@ -305,7 +315,7 @@ public class GlobalExceptionHandler {
|
||||
public ApiResponseDto<String> handlerMemberNotFoundException(
|
||||
MemberException.MemberNotFoundException e, HttpServletRequest request) {
|
||||
log.warn("[MemberNotFoundException] resource :{} ", e.getMessage());
|
||||
|
||||
this.errorLog(request, e);
|
||||
String codeName = "NOT_FOUND_USER";
|
||||
|
||||
ErrorLogEntity errorLog =
|
||||
@@ -328,7 +338,7 @@ public class GlobalExceptionHandler {
|
||||
public ApiResponseDto<String> handlerDuplicateKeyException(
|
||||
DuplicateKeyException e, HttpServletRequest request) {
|
||||
log.warn("[DuplicateKeyException] resource :{} ", e.getMessage());
|
||||
|
||||
this.errorLog(request, e);
|
||||
String codeName = "DUPLICATE_DATA";
|
||||
|
||||
ErrorLogEntity errorLog =
|
||||
@@ -350,7 +360,7 @@ public class GlobalExceptionHandler {
|
||||
public ResponseEntity<ApiResponseDto<String>> handleBadCredentials(
|
||||
BadCredentialsException e, HttpServletRequest request) {
|
||||
log.warn("[BadCredentialsException] resource : {} ", e.getMessage());
|
||||
|
||||
this.errorLog(request, e);
|
||||
String codeName = "UNAUTHORIZED";
|
||||
|
||||
ErrorLogEntity errorLog =
|
||||
@@ -377,7 +387,7 @@ public class GlobalExceptionHandler {
|
||||
public ApiResponseDto<String> handlerRuntimeException(
|
||||
RuntimeException e, HttpServletRequest request) {
|
||||
log.warn("[RuntimeException] resource :{} ", e.getMessage());
|
||||
|
||||
this.errorLog(request, e);
|
||||
String codeName = "INTERNAL_SERVER_ERROR";
|
||||
ErrorLogEntity errorLog =
|
||||
saveErrorLogData(
|
||||
@@ -397,8 +407,7 @@ public class GlobalExceptionHandler {
|
||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
@ExceptionHandler(Exception.class)
|
||||
public ApiResponseDto<String> handlerException(Exception e, HttpServletRequest request) {
|
||||
log.error("[Exception] resource: {}, message: {}", request.getRequestURI(), e.getMessage());
|
||||
log.error("Exception stacktrace: ", e);
|
||||
this.errorLog(request, e);
|
||||
|
||||
String codeName = "INTERNAL_SERVER_ERROR";
|
||||
ErrorLogEntity errorLog =
|
||||
@@ -454,8 +463,7 @@ public class GlobalExceptionHandler {
|
||||
String stackTraceStr =
|
||||
Arrays.stream(stackTrace)
|
||||
.map(StackTraceElement::toString)
|
||||
.collect(Collectors.joining("\n"))
|
||||
.substring(0, Math.min(stackTrace.length, 255));
|
||||
.collect(Collectors.joining("\n"));
|
||||
|
||||
ErrorLogEntity errorLogEntity =
|
||||
new ErrorLogEntity(
|
||||
@@ -475,7 +483,7 @@ public class GlobalExceptionHandler {
|
||||
public ApiResponseDto<String> handleCustomApiException(
|
||||
CustomApiException e, HttpServletRequest request) {
|
||||
log.warn("[CustomApiException] resource : {}", e.getMessage());
|
||||
|
||||
this.errorLog(request, e);
|
||||
String codeName = e.getCodeName();
|
||||
HttpStatus status = e.getStatus();
|
||||
// String message = e.getMessage() == null ? ApiResponseCode.getMessage(codeName) :
|
||||
@@ -512,6 +520,7 @@ public class GlobalExceptionHandler {
|
||||
public ApiResponseDto<String> handleMaxUploadSizeExceeded(
|
||||
MaxUploadSizeExceededException e, HttpServletRequest request) {
|
||||
log.warn("[MaxUploadSizeExceededException] resource :{} ", e.getMessage());
|
||||
this.errorLog(request, e);
|
||||
ApiResponseCode code = ApiResponseCode.PAYLOAD_TOO_LARGE;
|
||||
ErrorLogEntity errorLog =
|
||||
saveErrorLogData(
|
||||
@@ -524,4 +533,15 @@ public class GlobalExceptionHandler {
|
||||
return ApiResponseDto.createException(
|
||||
code, code.getText(), HttpStatus.PAYLOAD_TOO_LARGE, errorLog.getId());
|
||||
}
|
||||
|
||||
private void errorLog(HttpServletRequest request, Throwable e) {
|
||||
String uri = request != null ? request.getRequestURI() : "N/A";
|
||||
|
||||
// 예외 타입명 (IllegalArgumentException, BadCredentialsException 등)
|
||||
String exceptionName = e.getClass().getSimpleName();
|
||||
|
||||
log.error("[{}] uri={}, message={}", exceptionName, uri, e.getMessage());
|
||||
|
||||
log.error("[{}] stacktrace", exceptionName, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -29,8 +28,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
public class MenuApiController {
|
||||
|
||||
private final MenuService menuService;
|
||||
|
||||
@Autowired private ObjectMapper objectMapper;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
@Operation(summary = "목록 조회", description = "모든 메뉴 조회")
|
||||
@ApiResponses(
|
||||
|
||||
@@ -4,15 +4,16 @@ import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||
import com.kamco.cd.kamcoback.model.dto.ModelMngDto;
|
||||
import com.kamco.cd.kamcoback.model.service.ModelMngService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.transaction.Transactional;
|
||||
import java.time.LocalDate;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Tag(name = "모델 관리", description = "모델 관리 API")
|
||||
@RequiredArgsConstructor
|
||||
@@ -40,4 +41,28 @@ public class ModelMngApiController {
|
||||
|
||||
return ApiResponseDto.ok(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "삭제", description = "모델을 삭제 합니다.")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
responseCode = "204",
|
||||
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)
|
||||
})
|
||||
@DeleteMapping("/{modelVer}")
|
||||
public ApiResponseDto<ApiResponseDto.ResponseObj> removeModel(
|
||||
@io.swagger.v3.oas.annotations.parameters.RequestBody(
|
||||
description = "모델 삭제 요청 정보",
|
||||
required = true)
|
||||
@PathVariable
|
||||
String modelVer) {
|
||||
return ApiResponseDto.okObject(modelMngService.removeModel(modelVer));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,10 +69,10 @@ public class ModelMngDto {
|
||||
public static class ModelList {
|
||||
private Integer rowNum;
|
||||
private String modelVer;
|
||||
private String dockerFileNm;
|
||||
private String fileName;
|
||||
private String modelType;
|
||||
private String createCompleteDttm;
|
||||
private String recentUseDttm; // TODO: 추론관리 테이블 나오면 분석진행중일 때 사용중으로 리턴하기
|
||||
private String recentUseDttm;
|
||||
private BigDecimal f1Score;
|
||||
private BigDecimal precision;
|
||||
private BigDecimal recall;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.kamco.cd.kamcoback.model.service;
|
||||
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||
import com.kamco.cd.kamcoback.model.dto.ModelMngDto;
|
||||
import com.kamco.cd.kamcoback.postgres.core.ModelMngCoreService;
|
||||
import java.time.LocalDate;
|
||||
@@ -22,4 +23,8 @@ public class ModelMngService {
|
||||
return modelMngCoreService.findModelMgmtList(
|
||||
searchReq, startDate, endDate, modelType, searchVal);
|
||||
}
|
||||
|
||||
public ApiResponseDto.ResponseObj removeModel(String modelVer) {
|
||||
return modelMngCoreService.removeModel(modelVer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.kamco.cd.kamcoback.postgres.core;
|
||||
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||
import com.kamco.cd.kamcoback.model.dto.ModelMngDto;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.ModelMngEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.repository.model.ModelMngRepository;
|
||||
import jakarta.persistence.EntityNotFoundException;
|
||||
import java.time.LocalDate;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -22,4 +25,15 @@ public class ModelMngCoreService {
|
||||
return modelMngRepository.findModelMgmtList(
|
||||
searchReq, startDate, endDate, modelType, searchVal);
|
||||
}
|
||||
|
||||
public ApiResponseDto.ResponseObj removeModel(String modelVer) {
|
||||
ModelMngEntity entity =
|
||||
modelMngRepository
|
||||
.findByModelUid(modelVer)
|
||||
.orElseThrow(() -> new EntityNotFoundException("model을 찾을 수 없습니다. ver: " + modelVer));
|
||||
|
||||
// id 코드 deleted = true 업데이트
|
||||
entity.deleted();
|
||||
return new ApiResponseDto.ResponseObj(ApiResponseDto.ApiResponseCode.OK, "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.kamco.cd.kamcoback.log.dto.ErrorLogDto;
|
||||
import com.kamco.cd.kamcoback.log.dto.EventType;
|
||||
import com.kamco.cd.kamcoback.postgres.CommonCreateEntity;
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import java.time.ZonedDateTime;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
@@ -33,8 +32,7 @@ public class ErrorLogEntity extends CommonCreateEntity {
|
||||
private String errorCode;
|
||||
private String errorMessage;
|
||||
|
||||
@Size(max = 255)
|
||||
@Column(name = "stack_trace")
|
||||
@Column(name = "stack_trace", columnDefinition = "TEXT")
|
||||
private String stackTrace;
|
||||
|
||||
private Long handlerUid;
|
||||
|
||||
@@ -19,15 +19,6 @@ public class ModelMngEntity extends CommonDateEntity {
|
||||
@Column(name = "model_ver")
|
||||
private String modelVer;
|
||||
|
||||
@Column(name = "hyper_ver")
|
||||
private String hyperVer;
|
||||
|
||||
@Column(name = "epoch_ver")
|
||||
private String epochVer;
|
||||
|
||||
@Column(name = "docker_file_nm")
|
||||
private String dockerFileNm;
|
||||
|
||||
@Column(name = "create_complete_dttm")
|
||||
private ZonedDateTime createCompleteDttm;
|
||||
|
||||
@@ -42,4 +33,17 @@ public class ModelMngEntity extends CommonDateEntity {
|
||||
|
||||
@Column(name = "updated_uid")
|
||||
private Long updatedUid;
|
||||
|
||||
@Column(name = "model_type")
|
||||
private String modelType;
|
||||
|
||||
@Column(name = "file_path")
|
||||
private String filePath;
|
||||
|
||||
@Column(name = "file_name")
|
||||
private String fileName;
|
||||
|
||||
public void deleted() {
|
||||
this.deleted = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,7 @@ import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngEntity.mapSheet
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngFileEntity.mapSheetMngFileEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngHstEntity.mapSheetMngHstEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QYearEntity.yearEntity;
|
||||
import static java.lang.String.CASE_INSENSITIVE_ORDER;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.utils.FIleChecker.Folder;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity;
|
||||
import com.querydsl.core.BooleanBuilder;
|
||||
@@ -22,9 +20,7 @@ import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
import jakarta.validation.Valid;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -178,29 +174,28 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
public List<Integer> findMapSheetMngYyyyList() {
|
||||
|
||||
List<Integer> foundContent =
|
||||
queryFactory
|
||||
.select(yearEntity.yyyy)
|
||||
.from(yearEntity)
|
||||
.leftJoin(mapSheetMngEntity).on(mapSheetMngEntity.mngYyyy.eq(yearEntity.yyyy))
|
||||
.where(yearEntity.status.eq("NOTYET"))
|
||||
.orderBy(yearEntity.yyyy.asc())
|
||||
.limit(10)
|
||||
.fetch();
|
||||
|
||||
|
||||
queryFactory
|
||||
.select(yearEntity.yyyy)
|
||||
.from(yearEntity)
|
||||
.leftJoin(mapSheetMngEntity)
|
||||
.on(mapSheetMngEntity.mngYyyy.eq(yearEntity.yyyy))
|
||||
.where(yearEntity.status.eq("NOTYET"))
|
||||
.orderBy(yearEntity.yyyy.asc())
|
||||
.limit(10)
|
||||
.fetch();
|
||||
|
||||
foundContent.sort(Comparator.reverseOrder());
|
||||
|
||||
return foundContent;
|
||||
}
|
||||
|
||||
public void updateYearState(int yyyy, String status){
|
||||
public void updateYearState(int yyyy, String status) {
|
||||
long execCount =
|
||||
queryFactory
|
||||
.update(yearEntity)
|
||||
.set(yearEntity.status, status)
|
||||
.where(yearEntity.yyyy.eq(yyyy))
|
||||
.execute();
|
||||
queryFactory
|
||||
.update(yearEntity)
|
||||
.set(yearEntity.status, status)
|
||||
.where(yearEntity.yyyy.eq(yyyy))
|
||||
.execute();
|
||||
}
|
||||
|
||||
public MapSheetMngDto.MngDto findMapSheetMng(int mngYyyy) {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.model;
|
||||
|
||||
import com.kamco.cd.kamcoback.model.dto.ModelMngDto;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.ModelMngEntity;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
public interface ModelMngRepositoryCustom {
|
||||
@@ -12,4 +14,6 @@ public interface ModelMngRepositoryCustom {
|
||||
LocalDate endDate,
|
||||
String modelType,
|
||||
String searchVal);
|
||||
|
||||
Optional<ModelMngEntity> findByModelUid(String modelVer);
|
||||
}
|
||||
|
||||
@@ -9,10 +9,7 @@ import com.kamco.cd.kamcoback.postgres.entity.ModelMngEntity;
|
||||
import com.querydsl.core.BooleanBuilder;
|
||||
import com.querydsl.core.types.Expression;
|
||||
import com.querydsl.core.types.Projections;
|
||||
import com.querydsl.core.types.dsl.BooleanExpression;
|
||||
import com.querydsl.core.types.dsl.Expressions;
|
||||
import com.querydsl.core.types.dsl.NumberPath;
|
||||
import com.querydsl.core.types.dsl.StringExpression;
|
||||
import com.querydsl.core.types.dsl.*;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
@@ -21,6 +18,7 @@ import java.time.ZoneId;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -68,16 +66,9 @@ public class ModelMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
ModelMngDto.ModelList.class,
|
||||
Expressions.numberTemplate(
|
||||
Integer.class, "row_number() over(order by {0} desc)", sortColumn),
|
||||
Expressions.stringTemplate(
|
||||
"concat({0}, {1}, {2}, {3}, {4})",
|
||||
modelMngEntity.modelVer,
|
||||
".",
|
||||
modelMngEntity.hyperVer,
|
||||
".",
|
||||
modelMngEntity.epochVer)
|
||||
.as("modelVer"),
|
||||
modelMngEntity.dockerFileNm,
|
||||
modelMngEntity.modelVer.as("modelType"),
|
||||
modelMngEntity.modelVer,
|
||||
modelMngEntity.fileName,
|
||||
modelMngEntity.modelType,
|
||||
Expressions.stringTemplate(
|
||||
"to_char({0}, 'YYYY-MM-DD')", modelMngEntity.createCompleteDttm),
|
||||
Expressions.stringTemplate(
|
||||
@@ -93,7 +84,8 @@ public class ModelMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
.on(modelMngEntity.modelUid.eq(modelResultMetricEntity.modelUid))
|
||||
.where(
|
||||
eventEndedAtBetween(startDate, endDate, property),
|
||||
searchModelVersion(modelType, searchVal))
|
||||
searchModelVersion(modelType, searchVal),
|
||||
modelMngEntity.deleted.isFalse().or(modelMngEntity.deleted.isNull()))
|
||||
.offset(pageable.getOffset())
|
||||
.limit(pageable.getPageSize())
|
||||
.orderBy(
|
||||
@@ -113,6 +105,15 @@ public class ModelMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
return new PageImpl<>(foundContent, pageable, countQuery);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ModelMngEntity> findByModelUid(String modelVer) {
|
||||
return Optional.ofNullable(
|
||||
queryFactory
|
||||
.selectFrom(modelMngEntity)
|
||||
.where(modelMngEntity.modelVer.eq(modelVer))
|
||||
.fetchOne());
|
||||
}
|
||||
|
||||
private BooleanExpression eventEndedAtBetween(
|
||||
LocalDate startDate, LocalDate endDate, String sortColumn) {
|
||||
if (Objects.isNull(startDate) || Objects.isNull(endDate)) {
|
||||
@@ -139,11 +140,11 @@ public class ModelMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
BooleanBuilder builder = new BooleanBuilder();
|
||||
|
||||
if (Objects.nonNull(modelType)) {
|
||||
builder.and(modelMngEntity.modelVer.eq(modelType));
|
||||
builder.and(modelMngEntity.modelType.eq(modelType));
|
||||
}
|
||||
|
||||
if (Objects.nonNull(searchVal)) {
|
||||
builder.and(modelMngEntity.dockerFileNm.likeIgnoreCase("%" + searchVal + "%"));
|
||||
builder.and(modelMngEntity.modelVer.likeIgnoreCase("%" + searchVal + "%"));
|
||||
}
|
||||
|
||||
return builder;
|
||||
|
||||
Reference in New Issue
Block a user