import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { InvoiceTypeVO, InvoiceTypeForm, InvoiceTypeQuery } from '@/api/customer/invoiceType/types';

/**
 * 查询发票类型列表
 * @param query
 * @returns {*}
 */

export const listInvoiceType = (query?: InvoiceTypeQuery): AxiosPromise<InvoiceTypeVO[]> => {
  return request({
    url: '/system/invoiceType/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询发票类型详细
 * @param id
 */
export const getInvoiceType = (id: string | number): AxiosPromise<InvoiceTypeVO> => {
  return request({
    url: '/system/invoiceType/' + id,
    method: 'get'
  });
};

/**
 * 新增发票类型
 * @param data
 */
export const addInvoiceType = (data: InvoiceTypeForm) => {
  return request({
    url: '/system/invoiceType',
    method: 'post',
    data: data
  });
};

/**
 * 修改发票类型
 * @param data
 */
export const updateInvoiceType = (data: InvoiceTypeForm) => {
  return request({
    url: '/system/invoiceType',
    method: 'put',
    data: data
  });
};

/**
 * 删除发票类型
 * @param id
 */
export const delInvoiceType = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/invoiceType/' + id,
    method: 'delete'
  });
};
