import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SupplierVO, SupplierForm, SupplierQuery } from '@/api/warehouse/productSupplier/types';

/**
 * 查询供应商列表
 * @param query
 * @returns {*}
 */

export const listSupplier = (query?: SupplierQuery): AxiosPromise<SupplierVO[]> => {
  return request({
    url: '/warehouse/productSupplier/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询供应商详细
 * @param id
 */
export const getSupplier = (id: string | number): AxiosPromise<SupplierVO> => {
  return request({
    url: '/warehouse/productSupplier/' + id,
    method: 'get'
  });
};

/**
 * 新增供应商
 * @param data
 */
export const addSupplier = (data: SupplierForm) => {
  return request({
    url: '/warehouse/productSupplier',
    method: 'post',
    data: data
  });
};

/**
 * 修改供应商
 * @param data
 */
export const updateSupplier = (data: SupplierForm) => {
  return request({
    url: '/warehouse/productSupplier',
    method: 'put',
    data: data
  });
};

/**
 * 删除供应商
 * @param id
 */
export const delSupplier = (id: string | number | Array<string | number>) => {
  return request({
    url: '/warehouse/productSupplier/' + id,
    method: 'delete'
  });
};
