모델관리, 모델버전 조회,등록 진행중
This commit is contained in:
@@ -3,6 +3,7 @@ package com.kamco.cd.kamcoback.model;
|
||||
import com.kamco.cd.kamcoback.code.dto.CommonCodeDto;
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||
import com.kamco.cd.kamcoback.model.dto.ModelMngDto;
|
||||
import com.kamco.cd.kamcoback.model.dto.ModelVerDto;
|
||||
import com.kamco.cd.kamcoback.model.service.ModelMngService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
@@ -11,11 +12,10 @@ 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 lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Tag(name = "모델 관리", description = "모델 관리 API")
|
||||
@RequiredArgsConstructor
|
||||
@@ -43,4 +43,23 @@ public class ModelMngApiController {
|
||||
return ApiResponseDto.createOK(modelMngService.findModelMngAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* 최종 등록 모델 정보
|
||||
* @return ModelMngDto.FinalModelDto
|
||||
*/
|
||||
@Operation(summary = "최종 등록 모델 조회", description = "최종 등록 모델 조회")
|
||||
@GetMapping("/final-model-info")
|
||||
public ApiResponseDto<Optional<ModelMngDto.FinalModelDto>> getFinalModelInfo() {
|
||||
return ApiResponseDto.createOK(modelMngService.getFinalModelInfo());
|
||||
}
|
||||
|
||||
/**
|
||||
* 모델 등록 => 모델, 버전 동시 등록
|
||||
* @param addReq
|
||||
* @return
|
||||
*/
|
||||
@PostMapping
|
||||
public ApiResponseDto<ModelVerDto.Basic> save(@RequestBody ModelMngDto.AddReq addReq) {
|
||||
return ApiResponseDto.createOK(modelMngService.save(addReq));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,11 @@ package com.kamco.cd.kamcoback.model.dto;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.utils.interfaces.JsonFormatDttm;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
@@ -52,8 +56,45 @@ public class ModelMngDto {
|
||||
@Schema(name = "FinalModelDto", description = "최종 등록 모델")
|
||||
@Getter
|
||||
public static class FinalModelDto {
|
||||
private final Long modelUid;
|
||||
private final String modelNm;
|
||||
private final String modelCate;
|
||||
private final Long modelVerUid;
|
||||
private final String modelVer;
|
||||
private final String usedState;
|
||||
private final String modelState;
|
||||
private final Double qualityProb;
|
||||
private final String deployState;
|
||||
private final String modelPath;
|
||||
|
||||
public FinalModelDto(Long modelUid, String modelNm, String modelCate, Long modelVerUid, String modelVer,
|
||||
String usedState, String modelState, Double qualityProb, String deployState, String modelPath) {
|
||||
this.modelUid = modelUid;
|
||||
this.modelNm = modelNm;
|
||||
this.modelCate = modelCate;
|
||||
this.modelVerUid = modelVerUid;
|
||||
this.modelVer = modelVer;
|
||||
this.usedState = usedState;
|
||||
this.deployState = deployState;
|
||||
this.modelState = modelState;
|
||||
this.qualityProb = qualityProb;
|
||||
this.modelPath = modelPath;
|
||||
}
|
||||
}
|
||||
|
||||
@Schema(name = "ModelAddReq", description = "모델 버전 등록 req")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class AddReq {
|
||||
|
||||
@NotEmpty private Long modelUid;
|
||||
private String modelNm;
|
||||
private String modelCate;
|
||||
private String modelVer;
|
||||
private String modelPath;
|
||||
|
||||
@NotEmpty private String modelVer;
|
||||
private String modelCntnt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.kamco.cd.kamcoback.model.dto;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.utils.interfaces.JsonFormatDttm;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
public class ModelVerDto {
|
||||
|
||||
@Schema(name = "modelVer Basic", description = "모델버전 엔티티 기본 정보")
|
||||
@Getter
|
||||
public static class Basic {
|
||||
|
||||
private final Long id;
|
||||
private final Long modelUid;
|
||||
|
||||
private final String modelCate;
|
||||
private final String modelVer;
|
||||
|
||||
private final String usedState;
|
||||
private final String modelState;
|
||||
private final Double qualityProb;
|
||||
private final String deployState;
|
||||
private final String modelPath;
|
||||
|
||||
@JsonFormatDttm
|
||||
private final ZonedDateTime createdDttm;
|
||||
private final Long createdUid;
|
||||
|
||||
@JsonFormatDttm
|
||||
private final ZonedDateTime updatedDttm;
|
||||
private final Long updatedUid;
|
||||
|
||||
public Basic(
|
||||
Long id,
|
||||
Long modelUid,
|
||||
String modelCate,
|
||||
String modelVer,
|
||||
String usedState,
|
||||
String modelState,
|
||||
Double qualityProb,
|
||||
String deployState,
|
||||
String modelPath,
|
||||
ZonedDateTime createdDttm,
|
||||
Long createdUid,
|
||||
ZonedDateTime updatedDttm,
|
||||
Long updatedUid
|
||||
) {
|
||||
this.id = id;
|
||||
this.modelUid = modelUid;
|
||||
this.modelCate = modelCate;
|
||||
this.modelVer = modelVer;
|
||||
this.usedState = usedState;
|
||||
this.modelState = modelState;
|
||||
this.qualityProb = qualityProb;
|
||||
this.deployState = deployState;
|
||||
this.modelPath = modelPath;
|
||||
this.createdDttm = createdDttm;
|
||||
this.createdUid = createdUid;
|
||||
this.updatedDttm = updatedDttm;
|
||||
this.updatedUid = updatedUid;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
package com.kamco.cd.kamcoback.model.service;
|
||||
|
||||
import com.kamco.cd.kamcoback.model.dto.ModelMngDto;
|
||||
import com.kamco.cd.kamcoback.model.dto.ModelVerDto;
|
||||
import com.kamco.cd.kamcoback.postgres.core.ModelMngCoreService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@@ -19,4 +21,11 @@ public class ModelMngService {
|
||||
return modelMngCoreService.findModelMngAll();
|
||||
}
|
||||
|
||||
public Optional<ModelMngDto.FinalModelDto> getFinalModelInfo() {
|
||||
return modelMngCoreService.getFinalModelInfo();
|
||||
}
|
||||
|
||||
public ModelVerDto.Basic save(ModelMngDto.AddReq addReq) {
|
||||
return modelMngCoreService.save(addReq);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
package com.kamco.cd.kamcoback.postgres.core;
|
||||
|
||||
import com.kamco.cd.kamcoback.model.dto.ModelMngDto;
|
||||
import com.kamco.cd.kamcoback.model.dto.ModelVerDto;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.ModelMngEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.ModelVerEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.repository.model.ModelMngRepository;
|
||||
import com.kamco.cd.kamcoback.postgres.repository.model.ModelVerRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@@ -15,8 +19,23 @@ import java.util.List;
|
||||
public class ModelMngCoreService {
|
||||
|
||||
private final ModelMngRepository modelMngRepository;
|
||||
private final ModelVerRepository modelVerRepository;
|
||||
|
||||
public List<ModelMngDto.Basic> findModelMngAll() {
|
||||
return modelMngRepository.findModelMngAll().stream().map(ModelMngEntity::toDto).toList();
|
||||
}
|
||||
|
||||
public Optional<ModelMngDto.FinalModelDto> getFinalModelInfo(){
|
||||
return modelMngRepository.getFinalModelInfo();
|
||||
}
|
||||
|
||||
public ModelVerDto.Basic save(ModelMngDto.AddReq addReq) {
|
||||
ModelMngEntity modelMngEntity = new ModelMngEntity(addReq.getModelNm(), addReq.getModelCate(), addReq.getModelPath(),
|
||||
1L, 1L, addReq.getModelCntnt()); //TODO: 로그인 기능 붙이면 Uid 넣어야 함
|
||||
|
||||
ModelMngEntity saved = modelMngRepository.save(modelMngEntity);
|
||||
ModelVerEntity modelVerEntity = new ModelVerEntity(saved.getId(), addReq.getModelCate(), addReq.getModelVer(), "NONE", "NONE",
|
||||
0.0, "NONE", addReq.getModelPath(), 1L, 1L);
|
||||
return modelVerRepository.save(modelVerEntity).toDto();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class MapSheetAnalEntity {
|
||||
@Column(name = "anal_end_dttm")
|
||||
private ZonedDateTime analEndDttm;
|
||||
|
||||
@Column(name = "anal_ss")
|
||||
@Column(name = "anal_sec")
|
||||
private Integer analSs;
|
||||
|
||||
@Size(max = 20)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.kamco.cd.kamcoback.postgres.entity;
|
||||
|
||||
import com.kamco.cd.kamcoback.model.dto.ModelMngDto;
|
||||
import com.kamco.cd.kamcoback.postgres.CommonDateEntity;
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Getter;
|
||||
@@ -13,7 +14,7 @@ import java.time.ZonedDateTime;
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "tb_model_mng")
|
||||
public class ModelMngEntity {
|
||||
public class ModelMngEntity extends CommonDateEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "tb_model_mng_id_gen")
|
||||
@@ -36,30 +37,35 @@ public class ModelMngEntity {
|
||||
@Column(name = "model_path")
|
||||
private String modelPath;
|
||||
|
||||
@Column(name = "created_dttm")
|
||||
private ZonedDateTime createdDttm;
|
||||
|
||||
@Column(name = "created_uid")
|
||||
private Long createdUid;
|
||||
|
||||
@Column(name = "updated_dttm")
|
||||
private ZonedDateTime updatedDttm;
|
||||
|
||||
@Column(name = "updated_uid")
|
||||
private Long updatedUid;
|
||||
|
||||
@Column(name = "model_cntnt", columnDefinition = "TEXT")
|
||||
private String modelCntnt;
|
||||
|
||||
public ModelMngEntity(String modelNm, String modelCate, String modelPath,
|
||||
Long createdUid, Long updatedUid, String modelCntnt) {
|
||||
this.modelNm = modelNm;
|
||||
this.modelCate = modelCate;
|
||||
this.modelPath = modelPath;
|
||||
this.modelCntnt = modelCntnt;
|
||||
|
||||
this.createdUid = createdUid;
|
||||
this.updatedUid = updatedUid;
|
||||
}
|
||||
|
||||
public ModelMngDto.Basic toDto() {
|
||||
return new ModelMngDto.Basic(
|
||||
this.id,
|
||||
this.modelNm,
|
||||
this.modelCate,
|
||||
this.modelPath,
|
||||
this.createdDttm,
|
||||
super.getCreatedDate(),
|
||||
this.createdUid,
|
||||
this.updatedDttm,
|
||||
super.getModifiedDate(),
|
||||
this.updatedUid,
|
||||
this.modelCntnt);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.kamco.cd.kamcoback.postgres.entity;
|
||||
|
||||
import com.kamco.cd.kamcoback.model.dto.ModelMngDto;
|
||||
import com.kamco.cd.kamcoback.model.dto.ModelVerDto;
|
||||
import com.kamco.cd.kamcoback.postgres.CommonDateEntity;
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
@@ -13,7 +16,7 @@ import java.time.ZonedDateTime;
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "tb_model_ver")
|
||||
public class ModelVerEntity {
|
||||
public class ModelVerEntity extends CommonDateEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "tb_model_ver_id_gen")
|
||||
@@ -52,17 +55,40 @@ public class ModelVerEntity {
|
||||
@Column(name = "model_path")
|
||||
private String modelPath;
|
||||
|
||||
@ColumnDefault("now()")
|
||||
@Column(name = "created_dttm")
|
||||
private ZonedDateTime createdDttm;
|
||||
|
||||
@Column(name = "created_uid")
|
||||
private Long createdUid;
|
||||
|
||||
@Column(name = "updated_dttm")
|
||||
private ZonedDateTime updatedDttm;
|
||||
|
||||
@Column(name = "updated_uid")
|
||||
private Long updatedUid;
|
||||
|
||||
public ModelVerEntity(Long modelUid, String modelCate, String modelVer, String usedState, String modelState,
|
||||
Double qualityProb, String deployState, String modelPath, Long createdUid, Long updatedUid) {
|
||||
this.modelUid = modelUid;
|
||||
this.modelCate = modelCate;
|
||||
this.modelVer = modelVer;
|
||||
this.usedState = usedState;
|
||||
this.modelState = modelState;
|
||||
this.qualityProb = qualityProb;
|
||||
this.deployState = deployState;
|
||||
this.modelPath = modelPath;
|
||||
this.createdUid = createdUid;
|
||||
this.updatedUid = updatedUid;
|
||||
}
|
||||
|
||||
public ModelVerDto.Basic toDto() {
|
||||
return new ModelVerDto.Basic(
|
||||
this.id,
|
||||
this.modelUid,
|
||||
this.modelCate,
|
||||
this.modelVer,
|
||||
this.usedState,
|
||||
this.modelState,
|
||||
this.qualityProb,
|
||||
this.deployState,
|
||||
this.modelPath,
|
||||
super.getCreatedDate(),
|
||||
this.createdUid,
|
||||
super.getModifiedDate(),
|
||||
this.updatedUid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,11 @@ import com.kamco.cd.kamcoback.model.dto.ModelMngDto;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.ModelMngEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface ModelMngRepositoryCustom {
|
||||
|
||||
List<ModelMngEntity> findModelMngAll();
|
||||
|
||||
Optional<ModelMngDto.FinalModelDto> getFinalModelInfo();
|
||||
}
|
||||
|
||||
@@ -2,12 +2,14 @@ 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 com.querydsl.core.types.Projections;
|
||||
import com.querydsl.core.types.dsl.Expressions;
|
||||
import com.querydsl.core.types.dsl.StringExpression;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import org.springframework.data.jpa.repository.support.QuerydslRepositorySupport;
|
||||
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QModelMngEntity.modelMngEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QModelVerEntity.modelVerEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -31,7 +33,30 @@ public class ModelMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
.fetch();
|
||||
}
|
||||
|
||||
public Optional<?> findFinalModel(){
|
||||
return null;
|
||||
@Override
|
||||
public Optional<ModelMngDto.FinalModelDto> getFinalModelInfo(){
|
||||
return Optional.ofNullable(
|
||||
queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
ModelMngDto.FinalModelDto.class,
|
||||
modelMngEntity.id.as("modelUid"),
|
||||
modelMngEntity.modelNm,
|
||||
modelMngEntity.modelCate,
|
||||
modelVerEntity.id.as("modelVerUid"),
|
||||
modelVerEntity.modelVer,
|
||||
modelVerEntity.usedState,
|
||||
modelVerEntity.modelState,
|
||||
modelVerEntity.qualityProb,
|
||||
modelVerEntity.deployState,
|
||||
modelVerEntity.modelPath
|
||||
)
|
||||
)
|
||||
.from(modelMngEntity)
|
||||
.innerJoin(modelVerEntity)
|
||||
.on(modelMngEntity.id.eq(modelVerEntity.modelUid))
|
||||
.where(modelVerEntity.usedState.eq("USED"))
|
||||
.fetchOne()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.model;
|
||||
|
||||
import com.kamco.cd.kamcoback.postgres.entity.ModelMngEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.ModelVerEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface ModelVerRepository extends JpaRepository<ModelVerEntity, Long>, ModelVerRepositoryCustom {}
|
||||
@@ -0,0 +1,14 @@
|
||||
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.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface ModelVerRepositoryCustom {
|
||||
|
||||
List<ModelMngEntity> findModelMngAll();
|
||||
|
||||
Optional<ModelMngDto.FinalModelDto> getFinalModelInfo();
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
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 com.querydsl.core.types.Projections;
|
||||
import com.querydsl.core.types.dsl.Expressions;
|
||||
import com.querydsl.core.types.dsl.StringExpression;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import org.springframework.data.jpa.repository.support.QuerydslRepositorySupport;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QModelMngEntity.modelMngEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QModelVerEntity.modelVerEntity;
|
||||
|
||||
public class ModelVerRepositoryImpl extends QuerydslRepositorySupport
|
||||
implements ModelVerRepositoryCustom {
|
||||
|
||||
private final JPAQueryFactory queryFactory;
|
||||
private final StringExpression NULL_STRING = Expressions.stringTemplate("cast(null as text)");
|
||||
|
||||
public ModelVerRepositoryImpl(JPAQueryFactory queryFactory) {
|
||||
super(ModelMngEntity.class);
|
||||
this.queryFactory = queryFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ModelMngEntity> findModelMngAll() {
|
||||
return queryFactory
|
||||
.selectFrom(modelMngEntity)
|
||||
.orderBy(modelMngEntity.id.desc())
|
||||
.fetch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ModelMngDto.FinalModelDto> getFinalModelInfo(){
|
||||
return Optional.ofNullable(
|
||||
queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
ModelMngDto.FinalModelDto.class,
|
||||
modelMngEntity.id.as("modelUid"),
|
||||
modelMngEntity.modelNm,
|
||||
modelMngEntity.modelCate,
|
||||
modelVerEntity.id.as("modelVerUid"),
|
||||
modelVerEntity.modelVer,
|
||||
modelVerEntity.usedState,
|
||||
modelVerEntity.modelState,
|
||||
modelVerEntity.qualityProb,
|
||||
modelVerEntity.deployState,
|
||||
modelVerEntity.modelPath
|
||||
)
|
||||
)
|
||||
.from(modelMngEntity)
|
||||
.innerJoin(modelVerEntity)
|
||||
.on(modelMngEntity.id.eq(modelVerEntity.modelUid))
|
||||
.where(modelVerEntity.usedState.eq("USED"))
|
||||
.fetchOne()
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user