import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PoolLinkAuditVO, PoolLinkAuditForm, PoolLinkAuditQuery } from '@/api/product/poolLinkAudit/types';

/**
 * 查询产品池和产品关联审核列表
 * @param query
 * @returns {*}
 */

export const listPoolLinkAudit = (query?: PoolLinkAuditQuery): AxiosPromise<PoolLinkAuditVO[]> => {
  return request({
    url: '/product/poolLinkAudit/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询产品池和产品关联审核详细
 * @param id
 */
export const getPoolLinkAudit = (id: string | number): AxiosPromise<PoolLinkAuditVO> => {
  return request({
    url: '/product/poolLinkAudit/' + id,
    method: 'get'
  });
};

/**
 * 新增产品池和产品关联审核
 * @param data
 */
export const addPoolLinkAudit = (data: PoolLinkAuditForm) => {
  return request({
    url: '/product/poolLinkAudit',
    method: 'post',
    data: data
  });
};

/**
 * 修改产品池和产品关联审核
 * @param data
 */
export const updatePoolLinkAudit = (data: PoolLinkAuditForm) => {
  return request({
    url: '/product/poolLinkAudit',
    method: 'put',
    data: data
  });
};

/**
 * 删除产品池和产品关联审核
 * @param id
 */
export const delPoolLinkAudit = (id: string | number | Array<string | number>) => {
  return request({
    url: '/product/poolLinkAudit/' + id,
    method: 'delete'
  });
};

/**
 * 批量添加商品到商品池
 * @param data 批量添加参数
 */
export interface BatchAddProductData {
  poolId: string | number;
  products: Array<{
    productId: string | number;
    agreementPrice?: number;
  }>;
}

export const batchAddProducts = (data: BatchAddProductData) => {
  return request({
    url: '/product/poolLinkAudit/batchAdd',
    method: 'post',
    data: data
  });
};
