package cn.com.ctop.kuaishou.modules.report.service.impl;

import cn.com.ctop.common.module.entity.CtopOauthToken;
import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyCreativeStatistic;
import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportHourlyCreativeStatisticMapper;
import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyCreativeStatisticService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 时报清洗数据
 *
 * @author jeecg-boot
 * @version V1.0
 * @date 2019-11-01
 */
@Service
public class KuaishouReportHourlyCreativeStatisticServiceImpl extends ServiceImpl<KuaishouReportHourlyCreativeStatisticMapper, KuaishouReportHourlyCreativeStatistic> implements IKuaishouReportHourlyCreativeStatisticService {
    @Autowired
    private KuaishouReportHourlyCreativeStatisticMapper statisticMapper;

    @Override
    public void updateCreativeReportHourlyStatistic(CtopOauthToken token, Date getDate) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        String dateString = format.format(getDate);
        statisticMapper.updateCreativeReportHourlyStatistic(token.getAccountId(), dateString);
    }

    @Override
    public void deleteHourlyReport(Date deleteDate) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        String dateString = format.format(deleteDate);
        statisticMapper.deleteHourlyReport(dateString);
    }
}
