import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { GameEventProjectVO, GameEventProjectForm, GameEventProjectQuery } from '@/api/system/gameEventProject/types';

/**
 * 查询赛事项目列表
 * @param query
 * @returns {*}
 */

export const listGameEventProject = (query?: GameEventProjectQuery): AxiosPromise<GameEventProjectVO[]> => {
  return request({
    url: '/system/gameEventProject/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询赛事项目列表（带实时统计：人数、队数、组数）
 */
export const listGameEventProjectWithStats = (query?: GameEventProjectQuery): AxiosPromise<GameEventProjectVO[]> => {
  return request({
    url: '/system/gameEventProject/listWithStats',
    method: 'get',
    params: query
  });
};

/**
 * 查询所有赛事的项目列表（用于项目库）
 * @param query
 * @returns {*}
 */
export const listAllGameEventProject = (query?: GameEventProjectQuery): AxiosPromise<GameEventProjectVO[]> => {
  return request({
    url: '/system/gameEventProject/listAll',
    method: 'get',
    params: query
  });
};

/**
 * 查询赛事项目详细
 * @param projectId
 */
export const getGameEventProject = (projectId: string | number): AxiosPromise<GameEventProjectVO> => {
  return request({
    url: '/system/gameEventProject/' + projectId,
    method: 'get'
  });
};

/**
 * 新增赛事项目
 * @param data
 */
export const addGameEventProject = (data: GameEventProjectForm) => {
  return request({
    url: '/system/gameEventProject',
    method: 'post',
    data: data
  });
};

/**
 * 批量新增赛事项目
 * @param data
 */
export const BatchAddProject = (data: GameEventProjectVO[]) => {
  return request({
    url: '/system/gameEventProject/BatchAdd',
    method: 'post',
    data: data
  });
};

/**
 * 修改赛事项目
 * @param data
 */
export const updateGameEventProject = (data: GameEventProjectForm) => {
  return request({
    url: '/system/gameEventProject',
    method: 'put',
    data: data
  });
};

/**
 * 删除赛事项目
 * @param projectId
 */
export const delGameEventProject = (projectId: string | number | Array<string | number>) => {
  return request({
    url: '/system/gameEventProject/' + projectId,
    method: 'delete'
  });
};

/**
 * 查询赛事项目数量
 * @returns {*}
 */
export const getEventProjectCount = () => {
  return request({
    url: '/system/gameEventProject/count',
    method: 'get'
  });
};
