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

import cn.com.ctop.kuaishou.modules.report.mapper.KsVideoReportMapper;
import cn.com.ctop.kuaishou.modules.report.service.IKsVideoReportService;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class KsVideoReportServiceImpl implements IKsVideoReportService {

    @Autowired
    KsVideoReportMapper ksVideoReportMapper;

    @Override
    public PageInfo<JSONObject> getVideoReportBy(JSONArray accountIds, String startDate, String endDate, String filed, String target, String order, String clip, String shot, String plan, int pageSize, int pageNo) {
        PageHelper.startPage(pageNo, pageSize);
        List<JSONObject> jsonObjectList = ksVideoReportMapper.queryVideoReportBy(accountIds, startDate, endDate, filed, target, order, clip, shot, plan);
        return new PageInfo<>(jsonObjectList);
    }

    @Override
    public List<JSONObject> getVideoDetailBy(JSONArray accountIds, String startDate, String endDate, String filed, String signature) {
        return ksVideoReportMapper.queryVideoDetailBy(accountIds, startDate, endDate, filed, signature);
    }

    @Override
    public List<JSONObject> exportExcelReportBy(JSONArray accountIds, String startDate, String endDate, String filed, String target, String order, String clip, String shot, String plan) {
        return ksVideoReportMapper.queryVideoReportBy(accountIds, startDate, endDate, filed, target, order, clip, shot, plan);
    }

    @Override
    public PageInfo<JSONObject> getKuaiShouVideoPageReportByMap(Map<String, Object> requestMap, int pageSize, int pageNo) {
        Long total = ksVideoReportMapper.getTotalByMap(requestMap);
        PageHelper.startPage(pageNo, pageSize, false);
        PageInfo pageInfo = new PageInfo(ksVideoReportMapper.getKuaiShouVideoReportByMap(requestMap));
        pageInfo.setTotal(total);
        return pageInfo;

    }

    @Override
    public List<JSONObject> getDesignList() {
        return ksVideoReportMapper.getDesignList();
    }

    @Override
    public List<JSONObject> getKuaiShouVideoReportByMap(Map<String, Object> requestMap) {
        List<JSONObject> jsonObjectList = ksVideoReportMapper.getKuaiShouVideoReportByMap(requestMap);
        return jsonObjectList;
    }

}
