import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ClassificationDiyVO, ClassificationDiyForm, ClassificationDiyQuery } from '@/api/product/classificationDiy/types';

/**
 * 查询商品自定义属性列表
 * @param query
 * @returns {*}
 */

export const listClassificationDiy = (query?: ClassificationDiyQuery): AxiosPromise<ClassificationDiyVO[]> => {
  return request({
    url: '/product/classificationDiy/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询商品自定义属性详细
 * @param id
 */
export const getClassificationDiy = (id: string | number): AxiosPromise<ClassificationDiyVO> => {
  return request({
    url: '/product/classificationDiy/' + id,
    method: 'get'
  });
};

/**
 * 新增商品自定义属性
 * @param data
 */
export const addClassificationDiy = (data: ClassificationDiyForm) => {
  return request({
    url: '/product/classificationDiy',
    method: 'post',
    data: data
  });
};

/**
 * 修改商品自定义属性
 * @param data
 */
export const updateClassificationDiy = (data: ClassificationDiyForm) => {
  return request({
    url: '/product/classificationDiy',
    method: 'put',
    data: data
  });
};

/**
 * 删除商品自定义属性
 * @param id
 */
export const delClassificationDiy = (id: string | number | Array<string | number>) => {
  return request({
    url: '/product/classificationDiy/' + id,
    method: 'delete'
  });
};
