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