import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { GameRefereeVO, GameRefereeForm, GameRefereeQuery } from '@/api/system/gameReferee/types';

/**
 * 查询裁判列表
 * @param query
 * @returns {*}
 */

export const listGameReferee = (query?: GameRefereeQuery): AxiosPromise<GameRefereeVO[]> => {
  return request({
    url: '/system/gameReferee/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询裁判详细
 * @param refereeId
 */
export const getGameReferee = (refereeId: string | number): AxiosPromise<GameRefereeVO> => {
  return request({
    url: '/system/gameReferee/' + refereeId,
    method: 'get'
  });
};

/**
 * 新增裁判
 * @param data
 */
export const addGameReferee = (data: GameRefereeForm) => {
  return request({
    url: '/system/gameReferee',
    method: 'post',
    data: data
  });
};

/**
 * 修改裁判
 * @param data
 */
export const updateGameReferee = (data: GameRefereeForm) => {
  return request({
    url: '/system/gameReferee',
    method: 'put',
    data: data
  });
};

/**
 * 删除裁判
 * @param refereeId
 */
export const delGameReferee = (refereeId: string | number | Array<string | number>) => {
  return request({
    url: '/system/gameReferee/' + refereeId,
    method: 'delete'
  });
};

/**
 * 查询裁判数量
 * @returns {*}
 */
export const getRefereeCount = () => {
  return request({
    url: '/system/gameReferee/count',
    method: 'get'
  });
};

/**
 * 生成裁判二维码
 * @param refereeId 裁判ID
 * @returns {*}
 */
export const generateRefereeQRCode = (refereeId: string | number): AxiosPromise<string> => {
  return request({
    url: '/system/gameReferee/qrcode/' + refereeId,
    method: 'get'
  });
};
