import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RecommendVO, RecommendForm, RecommendQuery } from '@/api/product/recommend/types';

/**
 * 查询产品推荐位配置列表
 * @param query
 * @returns {*}
 */

export const listRecommend = (query?: RecommendQuery): AxiosPromise<RecommendVO[]> => {
  return request({
    url: '/product/recommend/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询产品推荐位配置详细
 * @param id
 */
export const getRecommend = (id: string | number): AxiosPromise<RecommendVO> => {
  return request({
    url: '/product/recommend/' + id,
    method: 'get'
  });
};

/**
 * 新增产品推荐位配置
 * @param data
 */
export const addRecommend = (data: RecommendForm) => {
  return request({
    url: '/product/recommend',
    method: 'post',
    data: data
  });
};

/**
 * 修改产品推荐位配置
 * @param data
 */
export const updateRecommend = (data: RecommendForm) => {
  return request({
    url: '/product/recommend',
    method: 'put',
    data: data
  });
};

/**
 * 删除产品推荐位配置
 * @param id
 */
export const delRecommend = (id: string | number | Array<string | number>) => {
  return request({
    url: '/product/recommend/' + id,
    method: 'delete'
  });
};
