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 java.time.LocalDate;
import java.util.List;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

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

  private final ModelMngCoreService modelMngCoreService;

  public List<ModelMngDto.Basic> findModelMngAll() {
    return modelMngCoreService.findModelMngAll();
  }

  public Optional<ModelMngDto.FinalModelDto> getFinalModelInfo() {
    return modelMngCoreService.getFinalModelInfo();
  }

  public ModelVerDto.Basic save(ModelMngDto.AddReq addReq) {
    return modelMngCoreService.save(addReq);
  }

  public Long update(Long id, ModelMngDto.AddReq addReq) {
    return modelMngCoreService.update(id, addReq);
  }

  public Long delete(Long id) {
    return modelMngCoreService.delete(id);
  }

  public Page<ModelMngDto.ModelRegHistory> getRegHistoryList(
      ModelMngDto.searchReq searchReq, LocalDate startDate, LocalDate endDate, String searchVal) {
    return modelMngCoreService.getRegHistoryList(searchReq, startDate, endDate, searchVal);
  }
}
