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

import cn.com.ctop.common.module.utils.Check;
import cn.com.ctop.toutiao.modules.report.entity.ByteDanceCleanMaterialReport;
import cn.com.ctop.toutiao.modules.report.mapper.ByteDanceCleanMaterialReportMapper;
import cn.com.ctop.toutiao.modules.report.mapper.BytedanceCreativeDailyReportMapper;
import cn.com.ctop.toutiao.modules.report.service.IByteDanceCleanMaterialReportService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 头条-数据清洗
 *
 * @author jeecg-boot
 * @version V1.0
 * @date 2020-02-25
 */
@Service
@Primary

public class ByteDanceCleanMaterialReportServiceImpl extends ServiceImpl<ByteDanceCleanMaterialReportMapper, ByteDanceCleanMaterialReport> implements IByteDanceCleanMaterialReportService {
    @Autowired
    private BytedanceCreativeDailyReportMapper bytedanceCreativeDailyReportMapper;

    /**
     * 头条MD5 集合
     *
     * @return
     */
    @Override
    public List<String> getSignature() {
        return bytedanceCreativeDailyReportMapper.getSignatureList();
    }

    /**
     * 头条素材报表
     *
     * @param signature
     */
    @Override
    public void calculationMaterialReport(String signature) {
        if (Check.isNull(signature)) {
            return;
        }
        ByteDanceCleanMaterialReport calculationMaterialReport = bytedanceCreativeDailyReportMapper.calculationMaterialReport(signature);
        if (!Check.isNull(calculationMaterialReport)) {
            this.saveOrUpdate(calculationMaterialReport);
        }
    }
}
