import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ProductChangeLogVO, ProductChangeLogForm, ProductChangeLogQuery } from '@/api/external/productChangeLog/types';

/**
 * 查询商品变更消息记录列表
 * @param query
 * @returns {*}
 */

export const listProductChangeLog = (query?: ProductChangeLogQuery): AxiosPromise<ProductChangeLogVO[]> => {
  return request({
    url: '/external/productChangeLog/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询商品变更消息记录详细
 * @param id
 * @param itemId
 */
export const getProductChangeLog = (id: string | number, itemId?: string): AxiosPromise<ProductChangeLogVO> => {
  return request({
    url: '/external/productChangeLog/' + id,
    method: 'get',
    params: { itemId }
  });
};

/**
 * 新增商品变更消息记录
 * @param data
 */
export const addProductChangeLog = (data: ProductChangeLogForm) => {
  return request({
    url: '/external/productChangeLog',
    method: 'post',
    data: data
  });
};

/**
 * 修改商品变更消息记录
 * @param data
 */
export const updateProductChangeLog = (data: ProductChangeLogForm) => {
  return request({
    url: '/external/productChangeLog',
    method: 'put',
    data: data
  });
};

/**
 * 删除商品变更消息记录
 * @param id
 * @param itemId
 */
export const delProductChangeLog = (id: string | number | Array<string | number>, itemId?: string) => {
  return request({
    url: '/external/productChangeLog/' + id,
    method: 'delete',
    params: { itemId }
  });
};
