import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { EventGroupConfigVO, EventGroupConfigForm, EventGroupConfigQuery } from '@/api/system/business/eventGroupConfig/types';
import { ConfigVO } from '@/api/system/business/config/types';

/**
 * 查询赛事组别配置主列表
 * @param query
 * @returns {*}
 */

export const listEventGroupConfig = (query?: EventGroupConfigQuery): AxiosPromise<EventGroupConfigVO[]> => {
  return request({
    url: '/business/eventGroupConfig/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询赛事组别配置主详细
 * @param id
 */
export const getEventGroupConfig = (id: string | number): AxiosPromise<EventGroupConfigVO> => {
  return request({
    url: '/business/eventGroupConfig/' + id,
    method: 'get'
  });
};

/**
 * 新增赛事组别配置主
 * @param data
 */
export const addEventGroupConfig = (data: EventGroupConfigForm) => {
  return request({
    url: '/business/eventGroupConfig',
    method: 'post',
    data: data
  });
};

/**
 * 修改赛事组别配置主
 * @param data
 */
export const updateEventGroupConfig = (data: EventGroupConfigForm) => {
  return request({
    url: '/business/eventGroupConfig',
    method: 'put',
    data: data
  });
};

/**
 * 删除赛事组别配置主
 * @param id
 */
export const delEventGroupConfig = (id: string | number | Array<string | number>) => {
  return request({
    url: '/business/eventGroupConfig/' + id,
    method: 'delete'
  });
};
export const generateXiLieTournament = (eventId: string | number): AxiosPromise<EventGroupConfigVO> => {
  return request({
    url: '/business/eventGroupConfig/generateXiLieTournament',
    method: 'post',
    params: { eventId } // 添加 configId 参数传递
  });
};
