import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { WeightUnitVO, WeightUnitForm, WeightUnitQuery } from '@/api/product/weightUnit/types';

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

export const listWeightUnit = (query?: WeightUnitQuery): AxiosPromise<WeightUnitVO[]> => {
  return request({
    url: '/product/weightUnit/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询产品重量单位详细
 * @param id
 */
export const getWeightUnit = (id: string | number): AxiosPromise<WeightUnitVO> => {
  return request({
    url: '/product/weightUnit/' + id,
    method: 'get'
  });
};

/**
 * 新增产品重量单位
 * @param data
 */
export const addWeightUnit = (data: WeightUnitForm) => {
  return request({
    url: '/product/weightUnit',
    method: 'post',
    data: data
  });
};

/**
 * 修改产品重量单位
 * @param data
 */
export const updateWeightUnit = (data: WeightUnitForm) => {
  return request({
    url: '/product/weightUnit',
    method: 'put',
    data: data
  });
};

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