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.BytedanceCreativeHourlyReport;
import cn.com.ctop.toutiao.modules.report.mapper.BytedanceCreativeHourlyReportMapper;
import cn.com.ctop.toutiao.modules.report.service.IBytedanceCreativeHourlyReportService;
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;

/**
 * @Description: 广告创意日报表信息
 * @Author: jeecg-boot
 * @Date: 2019-09-11
 * @Version: V1.0
 */
@Service
@Primary

public class BytedanceCreativeHourlyReportServiceImpl extends ServiceImpl<BytedanceCreativeHourlyReportMapper, BytedanceCreativeHourlyReport> implements IBytedanceCreativeHourlyReportService {
    @Autowired
    private BytedanceCreativeHourlyReportMapper reportMapper;

    @Override
    public void replaceBatch(List<BytedanceCreativeHourlyReport> hourlyReports) {
        reportMapper.replaceBatch(hourlyReports);
    }

    @Override
    public String getSignatureByCreativeId(Long creativeId) {
        String videoId = reportMapper.getVideoIdByCreativeId(creativeId);
        if (!Check.isNull(videoId)) {
            String signature = reportMapper.selectSignatureByVideoId(videoId);
            if (!Check.isNull(signature)) {
                return signature;
            }
        }
        return null;
    }
}
