import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CustomizationVO, CustomizationForm, CustomizationQuery } from '@/api/product/customization/types';

/**
 * 查询产品定制信息列表
 * @param query
 * @returns {*}
 */

export const listCustomization = (query?: CustomizationQuery): AxiosPromise<CustomizationVO[]> => {
  return request({
    url: '/product/customization/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询产品定制信息详细
 * @param id
 */
export const getCustomization = (id: string | number): AxiosPromise<CustomizationVO> => {
  return request({
    url: '/product/customization/' + id,
    method: 'get'
  });
};

/**
 * 新增产品定制信息
 * @param data
 */
export const addCustomization = (data: CustomizationForm) => {
  return request({
    url: '/product/customization',
    method: 'post',
    data: data
  });
};

/**
 * 修改产品定制信息
 * @param data
 */
export const updateCustomization = (data: CustomizationForm) => {
  return request({
    url: '/product/customization',
    method: 'put',
    data: data
  });
};

/**
 * 删除产品定制信息
 * @param id
 */
export const delCustomization = (id: string | number | Array<string | number>) => {
  return request({
    url: '/product/customization/' + id,
    method: 'delete'
  });
};
