import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PriceInventoryVO, PriceInventoryForm, PriceInventoryQuery } from '@/api/product/priceInventory/types';

/**
 * 查询产品价格与库存信息列表
 * @param query
 * @returns {*}
 */

export const listPriceInventory = (query?: PriceInventoryQuery): AxiosPromise<PriceInventoryVO[]> => {
  return request({
    url: '/product/priceInventory/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询产品价格与库存信息详细
 * @param productId
 */
export const getPriceInventory = (productId: string | number): AxiosPromise<PriceInventoryVO> => {
  return request({
    url: '/product/priceInventory/' + productId,
    method: 'get'
  });
};

/**
 * 新增产品价格与库存信息
 * @param data
 */
export const addPriceInventory = (data: PriceInventoryForm) => {
  return request({
    url: '/product/priceInventory',
    method: 'post',
    data: data
  });
};

/**
 * 修改产品价格与库存信息
 * @param data
 */
export const updatePriceInventory = (data: PriceInventoryForm) => {
  return request({
    url: '/product/priceInventory',
    method: 'put',
    data: data
  });
};

/**
 * 删除产品价格与库存信息
 * @param productId
 */
export const delPriceInventory = (productId: string | number | Array<string | number>) => {
  return request({
    url: '/product/priceInventory/' + productId,
    method: 'delete'
  });
};
