package com.boot.security.server.dao;

import com.boot.security.server.model.AdvertiserData;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AdvertDao {
    @Select("select report_date reportDate,advertiser_id advertiserId,advertiser_name advertiserName,code_id codeId,ecpm,cpc,exposure,click,income from advert_data_count t where report_date>= #{startTime} and report_date<=#{endTime}")
    List<AdvertiserData> getAdvertData(@Param("startTime") String startTime, @Param("endTime") String endTime);

    @Select("select count(*) from advert_data_count t where report_date>= #{startTime} and report_date<=#{endTime}")
    Integer getAdvertDataCount(@Param("startTime") String startTime, @Param("endTime") String endTime);

    @Select("select advertiser_id advertiserId,advertiser_name advertiserName from advertiser_user_map t where user_id={#userId}")
    List<AdvertiserData> getAdvertiserByUserId(@Param("userId") String userId);

    @Select("select code_id codeId from advert_list t where advertiser_id={#advertiserId}")
    List<AdvertiserData> getAdvertDataById(@Param("advertiserId") String advertiserId);

    @Select("select *,advertiser_id advertiserId,advertiser_name,total_income totalIncome,income_seven incomeSeven,income_thirty incomeThirty,exposure_view exposureView,click_view clickView from advertiser_data_count t where advertiser_id={#advertiserId}")
    List<AdvertiserData> getAdvertiserDataById(@Param("advertiserId") String advertiserId);

    @Select("select minutes,sum(exposure) exposure,sum(click) click from advertiser_data_minutes t where advertiser_id={#advertiserId} and report_date<={#day} and report_date<={#day} group by minutes")
    List<AdvertiserData> getAdvertExCl(@Param("advertiserId") String advertiserId,@Param("day") String day);
}
