import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AfterSalesVO, AfterSalesForm, AfterSalesQuery } from '@/api/product/afterSales/types';

/**
 * 查询产品售后服务项列表
 * @param query
 * @returns {*}
 */

export const listAfterSales = (query?: AfterSalesQuery): AxiosPromise<AfterSalesVO[]> => {
  return request({
    url: '/product/afterSales/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询产品售后服务项详细
 * @param id
 */
export const getAfterSales = (id: string | number): AxiosPromise<AfterSalesVO> => {
  return request({
    url: '/product/afterSales/' + id,
    method: 'get'
  });
};

/**
 * 新增产品售后服务项
 * @param data
 */
export const addAfterSales = (data: AfterSalesForm) => {
  return request({
    url: '/product/afterSales',
    method: 'post',
    data: data
  });
};

/**
 * 修改产品售后服务项
 * @param data
 */
export const updateAfterSales = (data: AfterSalesForm) => {
  return request({
    url: '/product/afterSales',
    method: 'put',
    data: data
  });
};

/**
 * 删除产品售后服务项
 * @param id
 */
export const delAfterSales = (id: string | number | Array<string | number>) => {
  return request({
    url: '/product/afterSales/' + id,
    method: 'delete'
  });
};
