package org.springblade.modules.martial.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.springblade.modules.martial.pojo.entity.MartialAthlete;
import org.springblade.modules.martial.pojo.vo.MartialAthleteVO;

/**
 * Athlete Mapper 接口
 *
 * @author BladeX
 */
public interface MartialAthleteMapper extends BaseMapper<MartialAthlete> {

	/**
	 * 分页查询参赛选手（包含关联字段）
	 *
	 * @param page 分页对象
	 * @param athlete 查询条件
	 * @return 参赛选手VO分页数据
	 */
	IPage<MartialAthleteVO> selectAthleteVOPage(IPage<MartialAthleteVO> page, @Param("athlete") MartialAthlete athlete);

	/**
	 * Count distinct participants by id_card for a competition
	 */
	@org.apache.ibatis.annotations.Select("SELECT COUNT(DISTINCT id_card) FROM martial_athlete WHERE competition_id = #{competitionId} AND is_deleted = 0")
	Long countDistinctParticipants(@Param("competitionId") Long competitionId);

}
