import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { VolumeUnitVO, VolumeUnitForm, VolumeUnitQuery } from '@/api/product/volumeUnit/types';

/**
 * 查询产品体积单位列表
 * @param query
 * @returns {*}
 */

export const listVolumeUnit = (query?: VolumeUnitQuery): AxiosPromise<VolumeUnitVO[]> => {
  return request({
    url: '/product/volumeUnit/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询产品体积单位详细
 * @param id
 */
export const getVolumeUnit = (id: string | number): AxiosPromise<VolumeUnitVO> => {
  return request({
    url: '/product/volumeUnit/' + id,
    method: 'get'
  });
};

/**
 * 新增产品体积单位
 * @param data
 */
export const addVolumeUnit = (data: VolumeUnitForm) => {
  return request({
    url: '/product/volumeUnit',
    method: 'post',
    data: data
  });
};

/**
 * 修改产品体积单位
 * @param data
 */
export const updateVolumeUnit = (data: VolumeUnitForm) => {
  return request({
    url: '/product/volumeUnit',
    method: 'put',
    data: data
  });
};

/**
 * 删除产品体积单位
 * @param id
 */
export const delVolumeUnit = (id: string | number | Array<string | number>) => {
  return request({
    url: '/product/volumeUnit/' + id,
    method: 'delete'
  });
};
