import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { OrderProductVO, OrderProductForm, OrderProductQuery } from '@/api/order/orderProduct/types';

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

export const listOrderProduct = (query?: OrderProductQuery): AxiosPromise<OrderProductVO[]> => {
  return request({
    url: '/order/orderProduct/list',
    method: 'get',
    params: query
  });
};

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

/**
 * 新增订单商品明细
 * @param data
 */
export const addOrderProduct = (data: OrderProductForm) => {
  return request({
    url: '/order/orderProduct',
    method: 'post',
    data: data
  });
};

/**
 * 修改订单商品明细
 * @param data
 */
export const updateOrderProduct = (data: OrderProductForm) => {
  return request({
    url: '/order/orderProduct',
    method: 'put',
    data: data
  });
};

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