import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ProductSelfVO, ProductSelfForm, ProductSelfQuery } from '@/api/product/productSelf/types';

/**
 * 查询自营商品池列表
 * @param query
 * @returns {*}
 */

export const listProductSelf = (query?: ProductSelfQuery): AxiosPromise<ProductSelfVO[]> => {
  return request({
    url: '/product/productSelf/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询自营商品池详细
 * @param productId
 */
export const getProductSelf = (productId: string | number): AxiosPromise<ProductSelfVO> => {
  return request({
    url: '/product/productSelf/' + productId,
    method: 'get'
  });
};

/**
 * 新增自营商品池
 * @param data
 */
export const addProductSelf = (data: ProductSelfForm) => {
  return request({
    url: '/product/productSelf',
    method: 'post',
    data: data
  });
};

/**
 * 修改自营商品池
 * @param data
 */
export const updateProductSelf = (data: ProductSelfForm) => {
  return request({
    url: '/product/productSelf',
    method: 'put',
    data: data
  });
};

/**
 * 删除自营商品池
 * @param productId
 */
export const delProductSelf = (productId: string | number | Array<string | number>) => {
  return request({
    url: '/product/productSelf/' + productId,
    method: 'delete'
  });
};
