import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ClassificationVO, ClassificationForm, ClassificationQuery } from '@/api/product/classification/types';

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

export const listClassification = (query?: ClassificationQuery): AxiosPromise<ClassificationVO[]> => {
  return request({
    url: '/product/classification/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询产品属性关联详细
 * @param id
 */
export const getClassification = (id: string | number): AxiosPromise<ClassificationVO> => {
  return request({
    url: '/product/classification/' + id,
    method: 'get'
  });
};

/**
 * 新增产品属性关联
 * @param data
 */
export const addClassification = (data: ClassificationForm) => {
  return request({
    url: '/product/classification',
    method: 'post',
    data: data
  });
};

/**
 * 修改产品属性关联
 * @param data
 */
export const updateClassification = (data: ClassificationForm) => {
  return request({
    url: '/product/classification',
    method: 'put',
    data: data
  });
};

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