import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { GameEventGroupVO, GameEventGroupForm, GameEventGroupQuery } from '@/api/system/gameEventGroup/types';

/**
 * 查询赛事分组列表
 * @param query
 * @returns {*}
 */

export const listGameEventGroup = (query?: GameEventGroupQuery): AxiosPromise<GameEventGroupVO[]> => {
  return request({
    url: '/system/gameEventGroup/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询赛事分组详细
 * @param groupId
 */
export const getGameEventGroup = (groupId: string | number): AxiosPromise<GameEventGroupVO> => {
  return request({
    url: '/system/gameEventGroup/' + groupId,
    method: 'get'
  });
};

/**
 * 新增赛事分组
 * @param data
 */
export const addGameEventGroup = (data: GameEventGroupForm) => {
  return request({
    url: '/system/gameEventGroup',
    method: 'post',
    data: data
  });
};

/**
 * 修改赛事分组
 * @param data
 */
export const updateGameEventGroup = (data: GameEventGroupForm) => {
  return request({
    url: '/system/gameEventGroup',
    method: 'put',
    data: data
  });
};

/**
 * 删除赛事分组
 * @param groupId
 */
export const delGameEventGroup = (groupId: string | number | Array<string | number>) => {
  return request({
    url: '/system/gameEventGroup/' + groupId,
    method: 'delete'
  });
};

/**
 * 生成分组结果
 * @param groupId
 */
export const generateGroups = (groupId: string | number): AxiosPromise<any> => {
  return request({
    url: '/system/gameEventGroup/generateGroups/' + groupId,
    method: 'get'
  });
};

/**
 * 从数据库获取分组结果
 * @param groupId
 */
export const getGroupResultFromDB = (groupId: string | number): AxiosPromise<any> => {
  return request({
    url: '/system/gameEventGroup/getGroupResultFromDB/' + groupId,
    method: 'get'
  });
};
