import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { JudgeVO, JudgeForm, JudgeQuery } from '@/api/system/physical/judge/types';
import { LeagueTournamentVO } from '@/api/system/physical/leagueTournament/types';

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

export const listJudge = (query?: JudgeQuery): AxiosPromise<JudgeVO[]> => {
  return request({
    url: '/physical/judge/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询裁判管理详细
 * @param id
 */
export const getJudge = (id: string | number): AxiosPromise<JudgeVO> => {
  return request({
    url: '/physical/judge/' + id,
    method: 'get'
  });
};

/**
 * 新增裁判管理
 * @param data
 */
export const addJudge = (data: JudgeForm) => {
  return request({
    url: '/physical/judge',
    method: 'post',
    data: data
  });
};

/**
 * 修改裁判管理
 * @param data
 */
export const updateJudge = (data: JudgeForm) => {
  return request({
    url: '/physical/judge',
    method: 'put',
    data: data
  });
};

/**
 * 删除裁判管理
 * @param id
 */
export const delJudge = (id: string | number | Array<string | number>) => {
  return request({
    url: '/physical/judge/' + id,
    method: 'delete'
  });
};
/**
 * 下载盲注级别导入模板
 */
export const downloadImportTemplates = async () => {
  const res = await request({
    url: '/physical/judge/importTemplate',
    method: 'POST',
    responseType: 'blob'
  });
  return res;
};
export const uploadJudgeFileImport = (data: FormData) => {
  return request({
    url: '/physical/judge/uploadJudgeFileImport',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
};
export const selectPhysicalJudgeSelList = (): AxiosPromise<JudgeVO> => {
  return request({
    url: '/physical/judge/selectPhysicalJudgeSelList',
    method: 'get'
  });
};
