import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { TaxrateVO, TaxrateForm, TaxrateQuery } from '@/api/product/taxrate/types';

/**
 * 查询产品税率配置列表
 * @param query
 * @returns {*}
 */

export const listTaxrate = (query?: TaxrateQuery): AxiosPromise<TaxrateVO[]> => {
  return request({
    url: '/product/taxrate/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询产品税率配置详细
 * @param id
 */
export const getTaxrate = (id: string | number): AxiosPromise<TaxrateVO> => {
  return request({
    url: '/product/taxrate/' + id,
    method: 'get'
  });
};

/**
 * 新增产品税率配置
 * @param data
 */
export const addTaxrate = (data: TaxrateForm) => {
  return request({
    url: '/product/taxrate',
    method: 'post',
    data: data
  });
};

/**
 * 修改产品税率配置
 * @param data
 */
export const updateTaxrate = (data: TaxrateForm) => {
  return request({
    url: '/product/taxrate',
    method: 'put',
    data: data
  });
};

/**
 * 删除产品税率配置
 * @param id
 */
export const delTaxrate = (id: string | number | Array<string | number>) => {
  return request({
    url: '/product/taxrate/' + id,
    method: 'delete'
  });
};
