import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { GameAthleteVO, GameAthleteForm, GameAthleteQuery } from '@/api/system/gameAthlete/types';

/**
 * 查询参赛队员列表
 * @param query
 * @returns {*}
 */

export const listGameAthlete = (query?: GameAthleteQuery): AxiosPromise<GameAthleteVO[]> => {
  return request({
    url: '/system/gameAthlete/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询参赛队员详细
 * @param athleteId
 */
export const getGameAthlete = (athleteId: string | number): AxiosPromise<GameAthleteVO> => {
  return request({
    url: '/system/gameAthlete/' + athleteId,
    method: 'get'
  });
};

/**
 * 新增参赛队员
 * @param data
 */
export const addGameAthlete = (data: GameAthleteForm) => {
  return request({
    url: '/system/gameAthlete',
    method: 'post',
    data: data
  });
};

/**
 * 修改参赛队员
 * @param data
 */
export const updateGameAthlete = (data: GameAthleteForm) => {
  return request({
    url: '/system/gameAthlete',
    method: 'put',
    data: data
  });
};

/**
 * 删除参赛队员
 * @param athleteId
 */
export const delGameAthlete = (athleteId: string | number | Array<string | number>) => {
  return request({
    url: '/system/gameAthlete/' + athleteId,
    method: 'delete'
  });
};

/**
 * 校验项目选择
 * @param data 
 * @returns 
 */
export function validateProjectSelection(data: any) {
  return request({
    url: '/system/gameAthlete/validateProjectSelection',
    method: 'post',
    data: data
  });
}

/**
 * 获取项目参赛人数
 * @param projectId 
 * @param eventId
 */
export function getAthleteCount(projectId: string | number, eventId?: string | number): AxiosPromise<number> {
  return request({
    url: '/system/gameAthlete/count/' + projectId,
    method: 'get',
    params: { eventId }
  });
}

/**
 * 根据项目ID分页查询队伍详细信息
 * @param projectId 项目ID
 * @param query 分页参数
 */
export function listTeamByProject(projectId: string | number, query: any): AxiosPromise<any> {
  return request({
    url: '/system/gameAthlete/teamListByProject/' + projectId,
    method: 'get',
    params: query
  });
}