package com.pcloud.book.applet.dao.impl;

import com.pcloud.book.applet.dao.AppletLinkClickDao;
import com.pcloud.book.applet.dto.AppletChartDateDTO;
import com.pcloud.book.applet.dto.ExportClickDTO;
import com.pcloud.book.applet.dto.PvuvDTO;
import com.pcloud.book.applet.entity.AppletLinkClick;
import com.pcloud.common.core.dao.BaseDaoImpl;

import org.springframework.stereotype.Component;

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

/**
 * @ClassName com.pcloud.book.applet.dao.impl.AppletLinkClickDaoImpl
 * @Author zhuyajie
 * @Description
 * @Date 2020/5/11 13:56
 * @Version 1.0
 **/
@Component
public class AppletLinkClickDaoImpl extends BaseDaoImpl<AppletLinkClick> implements AppletLinkClickDao {

    @Override
    public  List<AppletChartDateDTO> mapPVUVByMonth(Integer typeId, Integer recordType, Long newsId){
        Map<String,Object> map = new HashMap<>();
        map.put("newsId",newsId);
        map.put("recordType",recordType);
        map.put("typeId",typeId);
        return getSessionTemplate().selectList(getStatement("mapPVUVByMonth"),map);
    }

    @Override
    public Map<Long, PvuvDTO> mapPVUV(Integer typeId, Integer recordType, List<Long> fromIds,Integer intervalDaya) {
        Map<String,Object> map = new HashMap<>();
        map.put("list",fromIds);
        map.put("recordType",recordType);
        map.put("typeId",typeId);
        map.put("intervalDaya",intervalDaya);
        return getSessionTemplate().selectMap(getStatement("mapPVUV"),map,"fromId");
    }

    @Override
    public Map<Long, PvuvDTO> mapCouponUseCount(List<Long> fromIds) {
        Map<String,Object> map = new HashMap<>();
        map.put("list",fromIds);
        return getSessionTemplate().selectMap(getStatement("mapCouponUseCount"),map,"fromId");
    }

    @Override
    public List<ExportClickDTO> getThirdGroup(Integer count, String startDate, String endDate) {
        Map<String,Object> map = new HashMap<>();
        map.put("count", count);
        map.put("startDate", startDate);
        map.put("endDate", endDate);
        return getSessionTemplate().selectList(getStatement("getThirdGroup"), map);
    }

    @Override
    public List<ExportClickDTO> getNormalGroup(Integer count, String startDate, String endDate) {
        Map<String,Object> map = new HashMap<>();
        map.put("count", count);
        map.put("startDate", startDate);
        map.put("endDate", endDate);
        return getSessionTemplate().selectList(getStatement("getNormalGroup"), map);
    }

    @Override
    public List<ExportClickDTO> getNews(Integer count, String startDate, String endDate) {
        Map<String,Object> map = new HashMap<>();
        map.put("count", count);
        map.put("startDate", startDate);
        map.put("endDate", endDate);
        return getSessionTemplate().selectList(getStatement("getNews"), map);
    }
}
