모델 상세 API 커밋
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
package com.kamco.cd.training.postgres.core;
|
||||
|
||||
import com.kamco.cd.training.common.exception.BadRequestException;
|
||||
import com.kamco.cd.training.common.exception.NotFoundException;
|
||||
import com.kamco.cd.training.common.utils.UserUtil;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.DetailSummary;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.HyperSummary;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.MappingDataset;
|
||||
import com.kamco.cd.training.postgres.entity.ModelMasterEntity;
|
||||
import com.kamco.cd.training.postgres.repository.model.ModelDetailRepository;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ModelTrainDetailCoreService {
|
||||
private final ModelDetailRepository modelDetailRepository;
|
||||
private final UserUtil userUtil;
|
||||
|
||||
/**
|
||||
* UUID로 모델 조회
|
||||
*
|
||||
* @param uuid UUID
|
||||
* @return 모델 Entity
|
||||
*/
|
||||
public ModelMasterEntity findByUuid(String uuid) {
|
||||
try {
|
||||
UUID uuidObj = UUID.fromString(uuid);
|
||||
return modelDetailRepository
|
||||
.findByUuid(uuidObj)
|
||||
.orElseThrow(() -> new NotFoundException("모델을 찾을 수 없습니다. UUID: " + uuid));
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new BadRequestException("잘못된 UUID 형식입니다: " + uuid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 상세정보 페이지 > 요약정보
|
||||
*
|
||||
* @param uuid
|
||||
* @return
|
||||
*/
|
||||
public DetailSummary getModelDetailSummary(UUID uuid) {
|
||||
return modelDetailRepository.getModelDetailSummary(uuid);
|
||||
}
|
||||
|
||||
public HyperSummary getByModelHyperParamSummary(UUID uuid) {
|
||||
return modelDetailRepository.getByModelHyperParamSummary(uuid);
|
||||
}
|
||||
|
||||
public List<MappingDataset> getByModelMappingDataset(UUID uuid) {
|
||||
return modelDetailRepository.getByModelMappingDataset(uuid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.kamco.cd.training.postgres.repository.model;
|
||||
|
||||
import com.kamco.cd.training.postgres.entity.ModelMasterEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface ModelDetailRepository
|
||||
extends JpaRepository<ModelMasterEntity, Long>, ModelDetailRepositoryCustom {}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.kamco.cd.training.postgres.repository.model;
|
||||
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.DetailSummary;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.HyperSummary;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.MappingDataset;
|
||||
import com.kamco.cd.training.postgres.entity.ModelMasterEntity;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface ModelDetailRepositoryCustom {
|
||||
|
||||
Optional<ModelMasterEntity> findByUuid(UUID uuid);
|
||||
|
||||
DetailSummary getModelDetailSummary(UUID uuid);
|
||||
|
||||
HyperSummary getByModelHyperParamSummary(UUID uuid);
|
||||
|
||||
List<MappingDataset> getByModelMappingDataset(UUID uuid);
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.kamco.cd.training.postgres.repository.model;
|
||||
|
||||
import static com.kamco.cd.training.postgres.entity.QDatasetEntity.datasetEntity;
|
||||
import static com.kamco.cd.training.postgres.entity.QModelDatasetEntity.modelDatasetEntity;
|
||||
import static com.kamco.cd.training.postgres.entity.QModelDatasetMappEntity.modelDatasetMappEntity;
|
||||
import static com.kamco.cd.training.postgres.entity.QModelHyperParamEntity.modelHyperParamEntity;
|
||||
import static com.kamco.cd.training.postgres.entity.QModelMasterEntity.modelMasterEntity;
|
||||
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.DetailSummary;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.HyperSummary;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.MappingDataset;
|
||||
import com.kamco.cd.training.postgres.entity.ModelMasterEntity;
|
||||
import com.querydsl.core.types.Projections;
|
||||
import com.querydsl.jpa.JPAExpressions;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
public class ModelDetailRepositoryImpl implements ModelDetailRepositoryCustom {
|
||||
|
||||
private final JPAQueryFactory queryFactory;
|
||||
|
||||
/**
|
||||
* 모델 조회
|
||||
*
|
||||
* @param uuid
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Optional<ModelMasterEntity> findByUuid(UUID uuid) {
|
||||
return Optional.ofNullable(
|
||||
queryFactory
|
||||
.select(modelMasterEntity)
|
||||
.from(modelMasterEntity)
|
||||
.where(modelMasterEntity.uuid.eq(uuid))
|
||||
.fetchOne());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DetailSummary getModelDetailSummary(UUID uuid) {
|
||||
return queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
DetailSummary.class,
|
||||
modelMasterEntity.id,
|
||||
modelMasterEntity.uuid,
|
||||
modelMasterEntity.modelNo,
|
||||
modelMasterEntity.modelVer,
|
||||
modelMasterEntity.step1StrtDttm,
|
||||
modelMasterEntity.step2EndDttm,
|
||||
modelMasterEntity.statusCd,
|
||||
modelMasterEntity.trainType))
|
||||
.from(modelMasterEntity)
|
||||
.where(modelMasterEntity.uuid.eq(uuid))
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HyperSummary getByModelHyperParamSummary(UUID uuid) {
|
||||
return queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
HyperSummary.class,
|
||||
modelHyperParamEntity.uuid,
|
||||
modelHyperParamEntity.id,
|
||||
modelHyperParamEntity.hyperVer,
|
||||
modelHyperParamEntity.backbone,
|
||||
modelHyperParamEntity.inputSize,
|
||||
modelHyperParamEntity.batchSize))
|
||||
.from(modelHyperParamEntity)
|
||||
.where(
|
||||
modelHyperParamEntity.id.eq(
|
||||
JPAExpressions.select(modelMasterEntity.hyperParamId)
|
||||
.from(modelMasterEntity)
|
||||
.where(modelMasterEntity.uuid.eq(uuid))))
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MappingDataset> getByModelMappingDataset(UUID uuid) {
|
||||
return queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
MappingDataset.class,
|
||||
modelMasterEntity.id,
|
||||
datasetEntity.dataType,
|
||||
datasetEntity.compareYyyy,
|
||||
datasetEntity.targetYyyy,
|
||||
datasetEntity.roundNo,
|
||||
modelDatasetEntity.buildingCnt,
|
||||
modelDatasetEntity.containerCnt,
|
||||
modelDatasetEntity.wasteCnt,
|
||||
modelDatasetEntity.landCoverCnt))
|
||||
.from(modelMasterEntity)
|
||||
.innerJoin(modelDatasetEntity)
|
||||
.on(modelMasterEntity.id.eq(modelDatasetEntity.model.id))
|
||||
.innerJoin(modelDatasetMappEntity)
|
||||
.on(modelMasterEntity.id.eq(modelDatasetMappEntity.modelUid))
|
||||
.innerJoin(datasetEntity)
|
||||
.on(modelDatasetMappEntity.datasetUid.eq(datasetEntity.id))
|
||||
.where(modelMasterEntity.uuid.eq(uuid))
|
||||
.fetch();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user