import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { TaxCodeVO, TaxCodeForm, TaxCodeQuery } from '@/api/system/taxCode/types';

/**
 * 查询税收编码列表
 * @param query
 * @returns {*}
 */

export const listTaxCode = (query?: TaxCodeQuery): AxiosPromise<TaxCodeVO[]> => {
  return request({
    url: '/system/taxCode/list',
    method: 'get',
    params: query
  });
};

/**
 * 获取税收编码树
 * @param query
 * @returns {*}
 */
export const getTaxCodeTree = (query?: TaxCodeQuery): AxiosPromise<any[]> => {
  return request({
    url: '/system/taxCode/tree',
    method: 'get',
    params: query
  });
};

/**
 * 查询税收编码详细
 * @param id
 */
export const getTaxCode = (id: string | number): AxiosPromise<TaxCodeVO> => {
  return request({
    url: '/system/taxCode/' + id,
    method: 'get'
  });
};

/**
 * 新增税收编码
 * @param data
 */
export const addTaxCode = (data: TaxCodeForm) => {
  return request({
    url: '/system/taxCode',
    method: 'post',
    data: data
  });
};

/**
 * 修改税收编码
 * @param data
 */
export const updateTaxCode = (data: TaxCodeForm) => {
  return request({
    url: '/system/taxCode',
    method: 'put',
    data: data
  });
};

/**
 * 删除税收编码
 * @param id
 */
export const delTaxCode = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/taxCode/' + id,
    method: 'delete'
  });
};
