package com.sptg.statistics.biz.mapper;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
import com.sptg.statistics.api.entity.StatisticsAdWatch;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

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

/**
 * title: StatisticsAdWatchMapper
 * package: com.sptg.statistics.biz.mapper
 * description:统计广告观看-DAO接口
 *
 *                
 *                
 */
public interface StatisticsAdWatchMapper extends BaseMapper<StatisticsAdWatch> {
    /**
     * 功能描述:更新记录机构位置
     * @param oldPosition 旧机构位置
     * @param newPosition 新机构位置
     * @return int
     *                
     *                       
     */
    @Update("update  statistics_ad_watch set   s_org_position=#{newPosition}  where s_org_position=#{oldPosition}")
    public int updateOrgPosition(@Param(value = "oldPosition")String oldPosition, @Param(value = "newPosition") String newPosition);

    /**
     * 功能描述:获取广告类别观看数量
     * @param page
     * @param wrapper
     * @return  List<Map<String, Object>>
     *                
     *                     
     */
    @Select("select COUNT(1) AS adWatchCount,adw.l_ad_type_id AS adTypeId,adw.s_ad_type_name AS adTypeName FROM " +
            "sptg_statistics.statistics_ad_watch adw,sptg_ad.ad_type at   WHERE adw.l_ad_type_id=at.l_id ${ew.sqlSegment}")
    public List<Map<String, Object>> getAdWatchRankForAdTypeList(Pagination page, @Param(value = "ew") Wrapper<StatisticsAdWatch> wrapper);
}
