Merge pull request 'feat/dev_251201' (#97) from feat/dev_251201 into develop
Reviewed-on: https://kamco.gitea.gs.dabeeo.com/dabeeo/kamco-dabeeo-backoffice/pulls/97
This commit is contained in:
@@ -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, "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.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