import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DeliverProductVO, DeliverProductForm, DeliverProductQuery } from '@/api/order/deliverProduct/types';

/**
 * 查询订单发货商品明细列表
 * @param query
 * @returns {*}
 */

export const listDeliverProduct = (query?: DeliverProductQuery): AxiosPromise<DeliverProductVO[]> => {
  return request({
    url: '/order/deliverProduct/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询订单发货商品明细详细
 * @param id
 */
export const getDeliverProduct = (id: string | number): AxiosPromise<DeliverProductVO> => {
  return request({
    url: '/order/deliverProduct/' + id,
    method: 'get'
  });
};

/**
 * 新增订单发货商品明细
 * @param data
 */
export const addDeliverProduct = (data: DeliverProductForm) => {
  return request({
    url: '/order/deliverProduct',
    method: 'post',
    data: data
  });
};

/**
 * 修改订单发货商品明细
 * @param data
 */
export const updateDeliverProduct = (data: DeliverProductForm) => {
  return request({
    url: '/order/deliverProduct',
    method: 'put',
    data: data
  });
};

/**
 * 删除订单发货商品明细
 * @param id
 */
export const delDeliverProduct = (id: string | number | Array<string | number>) => {
  return request({
    url: '/order/deliverProduct/' + id,
    method: 'delete'
  });
};
