모델 수정 진행중
This commit is contained in:
@@ -11,6 +11,7 @@ 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 lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -21,6 +22,7 @@ import java.util.Optional;
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/api/model")
|
||||
@Transactional
|
||||
public class ModelMngApiController {
|
||||
|
||||
private final ModelMngService modelMngService;
|
||||
@@ -40,7 +42,7 @@ public class ModelMngApiController {
|
||||
})
|
||||
@GetMapping
|
||||
public ApiResponseDto<List<ModelMngDto.Basic>> getFindAll() {
|
||||
return ApiResponseDto.createOK(modelMngService.findModelMngAll());
|
||||
return ApiResponseDto.ok(modelMngService.findModelMngAll());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,16 +52,22 @@ public class ModelMngApiController {
|
||||
@Operation(summary = "최종 등록 모델 조회", description = "최종 등록 모델 조회")
|
||||
@GetMapping("/final-model-info")
|
||||
public ApiResponseDto<Optional<ModelMngDto.FinalModelDto>> getFinalModelInfo() {
|
||||
return ApiResponseDto.createOK(modelMngService.getFinalModelInfo());
|
||||
return ApiResponseDto.ok(modelMngService.getFinalModelInfo());
|
||||
}
|
||||
|
||||
/**
|
||||
* 모델 등록 => 모델, 버전 동시 등록
|
||||
* @param addReq
|
||||
* @return
|
||||
* 모델 등록 => 모델, 버전 동시 등록 (UI 상 따로 등록하는 곳 없음)
|
||||
* @param addReq 모델 입력 값
|
||||
* @return ModelVerDto.Basic
|
||||
*/
|
||||
@Operation(summary = "모델 등록", description = "모델 등록")
|
||||
@PostMapping
|
||||
public ApiResponseDto<ModelVerDto.Basic> save(@RequestBody ModelMngDto.AddReq addReq) {
|
||||
return ApiResponseDto.createOK(modelMngService.save(addReq));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public ApiResponseDto<Long> update(@PathVariable Long id, @RequestBody ModelMngDto.AddReq addReq) {
|
||||
return ApiResponseDto.ok(modelMngService.update(id, addReq));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,6 @@ public class ModelMngDto {
|
||||
@AllArgsConstructor
|
||||
public static class AddReq {
|
||||
|
||||
@NotEmpty private Long modelUid;
|
||||
private String modelNm;
|
||||
private String modelCate;
|
||||
private String modelPath;
|
||||
|
||||
@@ -28,4 +28,8 @@ public class ModelMngService {
|
||||
public ModelVerDto.Basic save(ModelMngDto.AddReq addReq) {
|
||||
return modelMngCoreService.save(addReq);
|
||||
}
|
||||
|
||||
public Long update(Long id, ModelMngDto.AddReq addReq) {
|
||||
return modelMngCoreService.update(id, addReq);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,16 +6,15 @@ 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 jakarta.persistence.EntityNotFoundException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Transactional(readOnly = true)
|
||||
public class ModelMngCoreService {
|
||||
|
||||
private final ModelMngRepository modelMngRepository;
|
||||
@@ -38,4 +37,14 @@ public class ModelMngCoreService {
|
||||
0.0, "NONE", addReq.getModelPath(), 1L, 1L);
|
||||
return modelVerRepository.save(modelVerEntity).toDto();
|
||||
}
|
||||
|
||||
public Long update(Long id, ModelMngDto.AddReq addReq) {
|
||||
//조회
|
||||
return null;
|
||||
// ModelVerEntity existData = modelVerRepository.findModelVerById(id)
|
||||
// .orElseThrow(() -> new EntityNotFoundException("버전 id 에 대한 정보를 찾을 수 없습니다. id : " + id));
|
||||
//
|
||||
// ModelVerEntity modelVerEntity = new ModelVerEntity(saved.getId(), addReq.getModelCate(), addReq.getModelVer(), "NONE", "NONE",
|
||||
// 0.0, "NONE", addReq.getModelPath(), 1L, 1L);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,21 @@ public class ModelVerEntity extends CommonDateEntity {
|
||||
@Column(name = "updated_uid")
|
||||
private Long updatedUid;
|
||||
|
||||
public ModelVerEntity(Long id, Long modelUid, String modelCate, String modelVer, String usedState, String modelState,
|
||||
Double qualityProb, String deployState, String modelPath, Long createdUid, 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.createdUid = createdUid;
|
||||
this.updatedUid = 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;
|
||||
|
||||
@@ -2,13 +2,12 @@ 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.kamco.cd.kamcoback.postgres.entity.ModelVerEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface ModelVerRepositoryCustom {
|
||||
|
||||
List<ModelMngEntity> findModelMngAll();
|
||||
|
||||
Optional<ModelMngDto.FinalModelDto> getFinalModelInfo();
|
||||
Optional<ModelVerEntity> findModelVerById(Long id);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ 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.kamco.cd.kamcoback.postgres.entity.ModelVerEntity;
|
||||
import com.querydsl.core.types.Projections;
|
||||
import com.querydsl.core.types.dsl.Expressions;
|
||||
import com.querydsl.core.types.dsl.StringExpression;
|
||||
@@ -26,36 +27,10 @@ public class ModelVerRepositoryImpl extends QuerydslRepositorySupport
|
||||
}
|
||||
|
||||
@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"))
|
||||
public Optional<ModelVerEntity> findModelVerById(Long id) {
|
||||
return Optional.ofNullable(queryFactory
|
||||
.selectFrom(modelVerEntity)
|
||||
.where(modelVerEntity.id.eq(id)) //model_ver_uid
|
||||
.fetchOne()
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user