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

/**
 * 查询用户申诉列表
 * @param query
 * @returns {*}
 */
export const listComplaints = (query?: ComplaintsQuery): AxiosPromise<ComplaintsVO[]> => {
  return request({
    url: '/business/complaints/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询用户申诉详细
 * @param id
 */
export const getComplaints = (id: string | number): AxiosPromise<ComplaintsVO> => {
  return request({
    url: '/business/complaints/' + id,
    method: 'get'
  });
};

/**
 * 新增用户申诉
 * @param data
 */
export const addComplaints = (data: ComplaintsForm) => {
  return request({
    url: '/business/complaints',
    method: 'post',
    data: data
  });
};

/**
 * 修改用户申诉
 * @param data
 */
export const updateComplaints = (data: ComplaintsForm) => {
  return request({
    url: '/business/complaints',
    method: 'put',
    data: data
  });
};

/**
 * 删除用户申诉
 * @param id
 */
export const delComplaints = (id: string | number | Array<string | number>) => {
  return request({
    url: '/business/complaints/' + id,
    method: 'delete'
  });
};
/**
 * 获取所有用户名及排名
 * @param id
 */
export const getAllUserRankByTournamentId = (query?: ComplaintsQuery): AxiosPromise<ClaimsVO[]> => {
  return request({
    url: '/business/complaints/getAllUserRankByTournamentId',
    method: 'get',
    params: query
  });
};
