package com.viettel.campaign.repository.impl;

import com.viettel.campaign.model.CampaignCompleteCode;
import com.viettel.campaign.repository.CampaignCompleteCodeRepositoryCustom;
import com.viettel.campaign.web.dto.ResultDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import javax.persistence.EntityManager;

@Repository
public class CampaignCompleteCompleteCodeRepositoryIpml implements CampaignCompleteCodeRepositoryCustom {

    @Autowired
    EntityManager entityManager;

    private Logger log = LoggerFactory.getLogger(CampaignCompleteCompleteCodeRepositoryIpml.class);

    @Transactional
    public CampaignCompleteCode updateStatusById(Long id) {
        CampaignCompleteCode dto = new CampaignCompleteCode();
        try {
            CampaignCompleteCode e = entityManager.find(CampaignCompleteCode.class, id);
            e.setStatus(new Short("0")); // set status = 0 --> khong hoat dong
            entityManager.merge(e);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        return dto;
    }

    @Transactional
    public CampaignCompleteCode findMaxValueCampaignType(Long companySiteId) {
        CampaignCompleteCode result = new CampaignCompleteCode();
        try {

        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }

        return result;
    }
}
