import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ManufacturerVO, ManufacturerForm, ManufacturerQuery } from '@/api/warehouse/productManufacturer/types';

/**
 * 查询生产产商列表
 * @param query
 * @returns {*}
 */

export const listManufacturer = (query?: ManufacturerQuery): AxiosPromise<ManufacturerVO[]> => {
  return request({
    url: '/warehouse/productManufacturer/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询生产产商详细
 * @param id
 */
export const getManufacturer = (id: string | number): AxiosPromise<ManufacturerVO> => {
  return request({
    url: '/warehouse/productManufacturer/' + id,
    method: 'get'
  });
};

/**
 * 新增生产产商
 * @param data
 */
export const addManufacturer = (data: ManufacturerForm) => {
  return request({
    url: '/warehouse/productManufacturer',
    method: 'post',
    data: data
  });
};

/**
 * 修改生产产商
 * @param data
 */
export const updateManufacturer = (data: ManufacturerForm) => {
  return request({
    url: '/warehouse/productManufacturer',
    method: 'put',
    data: data
  });
};

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