package com.tzld.piaoquan.api.dao.mapper.contentplatform.ext;

import com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformDemandVideo;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface ContentPlatformDemandVideoMapperExt {

    int batchInsert(@Param("list") List<ContentPlatformDemandVideo> list);

    int deleteByDt(@Param("dt") String dt);

    int deleteByDtAndChannelName(@Param("dt") String dt, @Param("channelName") String channelName);

    List<ContentPlatformDemandVideo> selectByCondition(@Param("dt") String dt,
                                                       @Param("channelName") String channelName,
                                                       @Param("pointType") String pointType,
                                                       @Param("title") String title,
                                                       @Param("crowdSegment") String crowdSegment,
                                                       @Param("offset") int offset,
                                                       @Param("pageSize") int pageSize);

    int countByCondition(@Param("dt") String dt,
                         @Param("channelName") String channelName,
                         @Param("pointType") String pointType,
                         @Param("title") String title,
                         @Param("crowdSegment") String crowdSegment);

    String getMaxDt(@Param("channelName") String channelName);

    /**
     * 推荐场景候选池查询：按 demand_strategy 取指定 crowd_segment 的候选行，
     * 按 total_rov DESC, score DESC 排，最多取 limit 行。
     * dimension：等值过滤；dimensionExclude：排除该 dimension（包含 NULL 视为通过）；
     * demandFilterSortStrategyLike：对 demand_filter_sort_strategy 做 LIKE 过滤；
     * excludeSelfTitle=true 时过滤掉 video.title == demand_content_title 的行。
     */
    List<ContentPlatformDemandVideo> selectForRecommend(@Param("dt") String dt,
                                                       @Param("channelName") String channelName,
                                                       @Param("crowdSegment") String crowdSegment,
                                                       @Param("demandStrategy") String demandStrategy,
                                                       @Param("dimension") String dimension,
                                                       @Param("dimensionExclude") String dimensionExclude,
                                                       @Param("demandFilterSortStrategyLike") String demandFilterSortStrategyLike,
                                                       @Param("channelLevel3") String channelLevel3,
                                                       @Param("driveDimensionTime") String driveDimensionTime,
                                                       @Param("category") String category,
                                                       @Param("matchMethod") String matchMethod,
                                                       @Param("limit") int limit,
                                                       @Param("excludeSelfTitle") boolean excludeSelfTitle);

    List<ContentPlatformDemandVideo> selectActiveVideos(@Param("dt") String dt);

    int updateStatusByVideoId(@Param("videoId") Long videoId, @Param("dt") String dt, @Param("status") Integer status, @Param("updateTimestamp") Long updateTimestamp);
}
