package com.kamco.cd.training.hyperparam.service;

import com.kamco.cd.training.common.dto.HyperClsParam;
import com.kamco.cd.training.common.enums.ModelType;
import com.kamco.cd.training.hyperparam.dto.HyperClsParamDto;
import com.kamco.cd.training.hyperparam.dto.HyperParamDto.List;
import com.kamco.cd.training.hyperparam.dto.HyperParamDto.SearchReq;
import com.kamco.cd.training.postgres.core.HyperClsParamCoreService;
import java.util.UUID;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(readOnly = true)
@RequiredArgsConstructor
public class HyperClsParamService {

  private final HyperClsParamCoreService hyperClsParamCoreService;

  /**
   * 하이퍼 파라미터 목록 조회
   *
   * @param model
   * @param req
   * @return 목록
   */
  public Page<List> getHyperParamList(ModelType model, SearchReq req) {
    return hyperClsParamCoreService.findByHyperVerList(model, req);
  }

  /**
   * 하이퍼파라미터 등록
   *
   * @param createReq 등록 요청
   * @return 생성된 버전명
   */
  @Transactional
  public String createHyperParam(HyperClsParam createReq) {
    return hyperClsParamCoreService.createHyperParam(createReq).getHyperVer();
  }

  /**
   * 하이퍼파라미터 수정
   *
   * @param createReq
   * @return
   */
  @Transactional
  public String updateHyperParam(UUID uuid, HyperClsParam createReq) {
    return hyperClsParamCoreService.updateHyperParam(uuid, createReq);
  }

  /**
   * 하이퍼파라미터 삭제
   *
   * @param uuid
   */
  public void deleteHyperParam(UUID uuid) {
    hyperClsParamCoreService.deleteHyperParam(uuid);
  }

  /** 하이퍼파라미터 최적화 설정값 조회 */
  public HyperClsParamDto.Basic getInitHyperParam(ModelType model) {
    return hyperClsParamCoreService.getInitHyperParam(model);
  }

  /**
   * 하이퍼파라미터 상세 조회
   *
   * @param uuid
   * @return
   */
  public HyperClsParamDto.Basic getHyperParam(UUID uuid) {
    return hyperClsParamCoreService.getHyperParam(uuid);
  }
}
