package com.yonge.cooleshow.biz.dal.dao;

import java.util.List;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yonge.cooleshow.biz.dal.entity.ActivityEvaluationRecord;
import com.yonge.cooleshow.biz.dal.vo.ActivityRankingVo;
import com.yonge.cooleshow.biz.dal.wrapper.StatGroupWrapper;
import org.apache.ibatis.annotations.Param;
import com.yonge.cooleshow.biz.dal.entity.ActivityPlan;
import com.yonge.cooleshow.biz.dal.vo.ActivityPlanVo;
import com.yonge.cooleshow.biz.dal.dto.search.ActivityPlanSearch;


public interface ActivityPlanDao extends BaseMapper<ActivityPlan> {
	/**
	 * 查询详情
	 *
	 * @author liweifan
	 * @date 2022-08-04 10:19:49
	 * @return: com.yonge.cooleshow.biz.dal.vo.ActivityPlanVo
	 */
	ActivityPlanVo detail(@Param("id") Long id);

	/**
	 * 分页查询
	 *
	 * @author liweifan
	 * @date 2022-08-04 10:19:49
	 * @return: com.yonge.cooleshow.biz.dal.vo.ActivityPlanVo
	 */
	List<ActivityPlanVo> selectPage(@Param("page") IPage page, @Param("param") ActivityPlanSearch activityPlan);
	/**
	 <if test="param.startTime !=null or param.endTime !=null">
		 and NOT (
			 <trim prefixOverrides="OR">
				 <if test="param.startTime !=null">
					OR t.activity_end_ &lt; #{param.startTime}
				 </if>
				 <if test="param.endTime !=null">
					OR t.activity_start_ &gt; #{param.endTime}
				 </if>
			 </trim>
		 )
	 </if>
	 */

	/**
	 * 评测活动 活动难度
	 *
	 * @param activityPlanId 活动id
	 * @return
	 */
	String selectActivityPlanEvaluation(@Param("activityPlanId") Long activityPlanId);

	/**
	 * 查询需要变更状态的活动
	 *
	 * @return
	 */
    List<ActivityPlan> activityState();


	/**
	 * 获取用户参与的分享活动
	 *
	 * @param type   活动分享类型
	 * @param userId 用户id
	 * @return
	 */
	ActivityPlanVo selectActivityShare(@Param("type") String type, @Param("userId") Long userId);

	/**
	 * 活动参与人数统计
	 * @param activityIds 活动ID
	 * @return List<StatGroupWrapper>
	 */
    List<StatGroupWrapper> selectActivityParticipateStatInfo(@Param("activityIds") List<Long> activityIds);

	/**
	 * 活动获奖用户统计
	 * @param activityIds 活动ID
	 * @return List<StatGroupWrapper>
	 */
	List<StatGroupWrapper> selectActivityWinnerStatInfo(@Param("activityIds") List<Long> activityIds);

	/**
	 * 活动总分用户排名
	 * @param activityId 活动ID
	 * @param subjectId 声部ID
	 * @return List<ActivityRankingVo>
	 */
    List<ActivityRankingVo> selectActivityHighestScoreRankingInfo(@Param("activityId") Long activityId, @Param("subjectId") Long subjectId,
																  @Param("rankingScore") Double rankingScore, @Param("limit") Integer limit);

	/**
	 * 总分用户排名信息
	 * @param activityPlanId 活动ID
	 * @param subjectId 声部ID
	 * @param rankingScore 分数
	 * @param userId 用户ID
	 * @return ActivityRankingVo
	 */
	ActivityRankingVo selectActivityHighestScoreUserRanking(@Param("activityId") Long activityPlanId, @Param("subjectId") Long subjectId,
															@Param("rankingScore") Double rankingScore, @Param("userId") Long userId);
}