import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RecommendLinkVO, RecommendLinkForm, RecommendLinkQuery } from '@/api/product/recommendLink/types';

/**
 * 查询产品推荐关联列表
 * @param query
 * @returns {*}
 */

export const listRecommendLink = (query?: RecommendLinkQuery): AxiosPromise<RecommendLinkVO[]> => {
  return request({
    url: '/product/recommendLink/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询产品推荐关联详细
 * @param id
 */
export const getRecommendLink = (id: string | number): AxiosPromise<RecommendLinkVO> => {
  return request({
    url: '/product/recommendLink/' + id,
    method: 'get'
  });
};

/**
 * 新增产品推荐关联
 * @param data
 */
export const addRecommendLink = (data: RecommendLinkForm) => {
  return request({
    url: '/product/recommendLink',
    method: 'post',
    data: data
  });
};

/**
 * 修改产品推荐关联
 * @param data
 */
export const updateRecommendLink = (data: RecommendLinkForm) => {
  return request({
    url: '/product/recommendLink',
    method: 'put',
    data: data
  });
};

/**
 * 删除产品推荐关联
 * @param id
 */
export const delRecommendLink = (id: string | number | Array<string | number>) => {
  return request({
    url: '/product/recommendLink/' + id,
    method: 'delete'
  });
};
