package com.viettel.campaign.service.impl;

import com.viettel.campaign.repository.CampaignExecuteRepository;
import com.viettel.campaign.service.CampaignExecuteService;
import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.web.dto.ApParamDTO;
import com.viettel.campaign.web.dto.ContactCustResultDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CampaignExecuteServiceImp implements CampaignExecuteService {

    private static final Logger logger = LoggerFactory.getLogger(CampaignExecuteServiceImp.class);

    @Autowired
    CampaignExecuteRepository campaignExecuteRepository;

    //<editor-fold: hungtt>
    @Override
    public ResultDTO getComboBoxStatus(String companySiteId, String completeType) {
        ResultDTO resultDTO = new ResultDTO();
        try {
            List<ApParamDTO> lst = campaignExecuteRepository.getComboBoxStatus(companySiteId, completeType);
            resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
            resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
            resultDTO.setData(lst);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
        return resultDTO;
    }

    @Override
    public ResultDTO getComboCampaignType(String companySiteId) {
        ResultDTO resultDTO = new ResultDTO();
        try {
            List<ApParamDTO> lst = campaignExecuteRepository.getComboCampaignType(companySiteId);
            resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
            resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
            resultDTO.setData(lst);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
        return resultDTO;
    }

    @Override
    public ResultDTO searchInteractiveResult(CampaignRequestDTO dto) {
        ResultDTO resultDTO = new ResultDTO();
        try {
            resultDTO = campaignExecuteRepository.getInteractiveResult(dto);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
        return resultDTO;
    }
    //</editor-fold: hungtt>
}
