import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SpecsVO, SpecsForm, SpecsQuery } from '@/api/product/specs/types';

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

export const listSpecs = (query?: SpecsQuery): AxiosPromise<SpecsVO[]> => {
  return request({
    url: '/product/specs/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询产品规格关联详细
 * @param id
 */
export const getSpecs = (id: string | number): AxiosPromise<SpecsVO> => {
  return request({
    url: '/product/specs/' + id,
    method: 'get'
  });
};

/**
 * 新增产品规格关联
 * @param data
 */
export const addSpecs = (data: SpecsForm) => {
  return request({
    url: '/product/specs',
    method: 'post',
    data: data
  });
};

/**
 * 修改产品规格关联
 * @param data
 */
export const updateSpecs = (data: SpecsForm) => {
  return request({
    url: '/product/specs',
    method: 'put',
    data: data
  });
};

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