import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PushPoolLogVO, PushPoolLogForm, PushPoolLogQuery } from '@/api/external/pushPoolLog/types';

/**
 * 查询商品池推送记录列表
 * @param query
 * @returns {*}
 */

export const listPushPoolLog = (query?: PushPoolLogQuery): AxiosPromise<PushPoolLogVO[]> => {
  return request({
    url: '/external/pushPoolLog/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询商品池推送记录详细
 * @param id
 * @param itemId
 */
export const getPushPoolLog = (id: string | number, itemId?: string): AxiosPromise<PushPoolLogVO> => {
  return request({
    url: '/external/pushPoolLog/' + id,
    method: 'get',
    params: { itemId }
  });
};

/**
 * 新增商品池推送记录
 * @param data
 */
export const addPushPoolLog = (data: PushPoolLogForm) => {
  return request({
    url: '/external/pushPoolLog',
    method: 'post',
    data: data
  });
};

/**
 * 修改商品池推送记录
 * @param data
 */
export const updatePushPoolLog = (data: PushPoolLogForm) => {
  return request({
    url: '/external/pushPoolLog',
    method: 'put',
    data: data
  });
};

/**
 * 删除商品池推送记录
 * @param id
 * @param itemId
 */
export const delPushPoolLog = (id: string | number | Array<string | number>, itemId?: string) => {
  return request({
    url: '/external/pushPoolLog/' + id,
    method: 'delete',
    params: { itemId }
  });
};
