import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ComplaintVO, ComplaintForm, ComplaintQuery } from '@/api/system/physical/complaint/types';

/**
 * 查询用户投诉列表
 * @param query
 * @returns {*}
 */

export const listComplaint = (query?: ComplaintQuery): AxiosPromise<ComplaintVO[]> => {
  return request({
    url: '/physical/complaint/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询用户投诉详细
 * @param id
 */
export const getComplaint = (id: string | number): AxiosPromise<ComplaintVO> => {
  return request({
    url: '/physical/complaint/' + id,
    method: 'get'
  });
};

/**
 * 新增用户投诉
 * @param data
 */
export const addComplaint = (data: ComplaintForm) => {
  return request({
    url: '/physical/complaint',
    method: 'post',
    data: data
  });
};

/**
 * 修改用户投诉
 * @param data
 */
export const updateComplaint = (data: ComplaintForm) => {
  return request({
    url: '/physical/complaint',
    method: 'put',
    data: data
  });
};

/**
 * 删除用户投诉
 * @param id
 */
export const delComplaint = (id: string | number | Array<string | number>) => {
  return request({
    url: '/physical/complaint/' + id,
    method: 'delete'
  });
};
