package com.interplug.qcast.biz.specialNote;

import java.util.List;
import org.springframework.stereotype.Service;
import com.interplug.qcast.biz.specialNote.dto.SpecialNoteItemRequest;
import com.interplug.qcast.biz.specialNote.dto.SpecialNoteRequest;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Service
@RequiredArgsConstructor
public class SpecialNoteService {

  private final SpecialNoteMapper specialNoteMapper;

  /**
   * 견적 특이사항 저장
   * 
   * @param specialNoteRequest
   * @throws Exception
   */
  public void setSpecialNoteSave(SpecialNoteRequest specialNoteRequest) throws Exception {
    specialNoteMapper.setSpecialNoteSave(specialNoteRequest);
  }

  /**
   * 견적 특이사항 아이템 저장
   * 
   * @param specialNoteItemRequest
   * @throws Exception
   */
  public void setSpecialNoteItemSave(SpecialNoteItemRequest specialNoteItemRequest)
      throws Exception {
    specialNoteMapper.setSpecialNoteItemSave(specialNoteItemRequest);
  }

  /**
   * 견적 특이사항 동기화 - Batch
   * 
   * @param specialNoteList
   * @throws Exception
   */
  public void setSpecialNoteBatch(List<SpecialNoteRequest> specialNoteList) throws Exception {
    // 견적 특이사항 동기화
    for (SpecialNoteRequest specialNoteRequest : specialNoteList) {
      try {
        specialNoteMapper.setSpecialNoteSave(specialNoteRequest);
      } catch (Exception e) {
        log.error(e.getMessage());
      }
    }
  }

  /**
   * 견적 특이사항 아이템 동기화 - Batch
   * 
   * @param specialNoteItemList
   * @throws Exception
   */
  public void setSpecialNoteItemBatch(List<SpecialNoteItemRequest> specialNoteItemList)
      throws Exception {
    // 견적 특이사항 아이템 동기화
    for (SpecialNoteItemRequest specialNoteItemRequest : specialNoteItemList) {
      try {
        specialNoteMapper.setSpecialNoteItemSave(specialNoteItemRequest);
      } catch (Exception e) {
        log.error(e.getMessage());
      }
    }
  }

}
