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

import cn.com.ctop.common.module.utils.Check;
import cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouReportAccountDaily;
import cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouReportAccountHourly;
import cn.com.ctop.kuaishou.modules.report.mapper.EtlKuaishouReportAccountDailyMapper;
import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAccountMapper;
import cn.com.ctop.kuaishou.modules.report.service.IEtlKuaishouReportAccountDailyService;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 盯盘日数据
 *
 * @author jeecg-boot
 * @version V1.0
 * @date 2021-03-04
 */
@Service
public class EtlKuaishouReportAccountDailyServiceImpl extends ServiceImpl<EtlKuaishouReportAccountDailyMapper, EtlKuaishouReportAccountDaily> implements IEtlKuaishouReportAccountDailyService {

    @Autowired
    private KuaishouReportDailyAccountMapper dailyAccountMapper;

    @Autowired
    private EtlKuaishouReportAccountDailyMapper etlDailyAccountMapper;

    @Override
    public void queryEveryDayDataForAccount() {
        List<EtlKuaishouReportAccountHourly> list = dailyAccountMapper.queryEveryDayDataForAccount();
        if (!Check.isNull(list)) {
            etlDailyAccountMapper.replaceBatch(list);
        }
    }

    @Override
    public JSONObject getReportData(String startDate, String endDate, JSONArray accountIds) {
        return etlDailyAccountMapper.getReportData(startDate, endDate, accountIds);
    }
}
