import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { TournamentsVO, TournamentsForm, TournamentsQuery } from '@/api/system/physical/tournaments/types';

/**
 * 查询线下赛事列表
 * @param query
 * @returns {*}
 */

export const listTournaments = (query?: TournamentsQuery): AxiosPromise<TournamentsVO[]> => {
  return request({
    url: '/physical/tournaments/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询线下赛事详细
 * @param id
 */
export const getTournaments = (id: string | number): AxiosPromise<TournamentsVO> => {
  return request({
    url: '/physical/tournaments/' + id,
    method: 'get'
  });
};

/**
 * 新增线下赛事
 * @param data
 */
export const addTournaments = (data: TournamentsForm) => {
  return request({
    url: '/physical/tournaments',
    method: 'post',
    data: data
  });
};

/**
 * 修改线下赛事
 * @param data
 */
export const updateTournaments = (data: TournamentsForm) => {
  return request({
    url: '/physical/tournaments',
    method: 'put',
    data: data
  });
};
export const updateByTournament = (data: TournamentsForm) => {
  return request({
    url: '/physical/tournaments/updateByTournament',
    method: 'put',
    data: data
  });
};
/**
 * 删除线下赛事
 * @param id
 */
export const delTournaments = (id: string | number | Array<string | number>) => {
  return request({
    url: '/physical/tournaments/' + id,
    method: 'delete'
  });
};
/**
 * 查询联赛关联的线下赛事列表（无参）
 */
export const selectPhysicalTournamentsLeagueId = (): AxiosPromise<TournamentsVO[]> => {
  return request({
    url: '/physical/tournaments/selectPhysicalTournamentsLeagueId',
    method: 'get'
  });
};
