package com.dbnt.sims.faRpt.service;

import com.dbnt.sims.config.BaseService;
import com.dbnt.sims.faRpt.mapper.FaRptMapper;
import com.dbnt.sims.faRpt.model.FaRptBoard;
import com.dbnt.sims.faRpt.repository.FaRptBoardRepository;
import com.dbnt.sims.faRpt.repository.FaRptFileRepository;
import com.dbnt.sims.faRpt.repository.FaRptReadUserRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
@RequiredArgsConstructor
public class FaRptService extends BaseService {
  private final FaRptBoardRepository faRptBoardRepository;
  private final FaRptFileRepository faRptFileRepository;
  private final FaRptReadUserRepository faRptReadUserRepository;
  private final FaRptMapper faRptMapper;


  public List<FaRptBoard> selectFaRptList(FaRptBoard faRptBoard) {
    return faRptMapper.selectFaRptList(faRptBoard);
  }

  public Integer selectFaRptCnt(FaRptBoard faRptBoard) {
    return faRptMapper.selectFaRptCnt(faRptBoard);
  }

  public Integer saveFaRptBoard(FaRptBoard faRptBoard, List<Integer> deleteFileSeq) {
    return 0;
  }

  public FaRptBoard selectFaRptBoard(Integer faRptKey) {
    FaRptBoard faRptBoard = faRptBoardRepository.findById(faRptKey).orElse(null);
    faRptBoard.setFileList(faRptFileRepository.findByFaRptKey(faRptKey));
    faRptBoard.setReadUserList(faRptReadUserRepository.findByFaRptKey(faRptKey));
    return faRptBoard;
  }
}