import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ClaimsVO, ClaimsForm, ClaimsQuery } from '@/api/system/business/claims/types';

/**
 * 查询用户参赛列表
 * @param query
 * @returns {*}
 */

export const listClaims = (query?: ClaimsQuery): AxiosPromise<ClaimsVO[]> => {
  return request({
    url: '/business/claims/list',
    method: 'get',
    params: query
  });
};
/**
 * 查询用户参赛详细
 * @param id
 */
export const getClaims = (id: string | number): AxiosPromise<ClaimsVO> => {
  return request({
    url: '/business/claims/' + id,
    method: 'get'
  });
};

/**
 * 新增用户参赛
 * @param data
 */
export const addClaims = (data: ClaimsForm) => {
  return request({
    url: '/business/claims',
    method: 'post',
    data: data
  });
};

/**
 * 修改用户参赛
 * @param data
 */
export const updateClaims = (data: ClaimsForm) => {
  return request({
    url: '/business/claims',
    method: 'put',
    data: data
  });
};

/**
 * 删除用户参赛
 * @param id
 */
export const delClaims = (id: string | number | Array<string | number>) => {
  return request({
    url: '/business/claims/' + id,
    method: 'delete'
  });
};

/**
 * 删除本场比赛的用户奖励
 * @param data
 */
export const deleteClaim = (data: { id: number; tournamentId: number }) => {
  return request({
    url: '/business/claims/deleteByCriteria',
    method: 'post',
    data
  });
};

/**
 * 审核奖励发放
 * @param data
 */
export const auditSendReward = (data: ClaimsForm) => {
  return request({
    url: '/business/claims/auditSendReward',
    method: 'POST',
    data: data
  });
};
