import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ProductsVO, ProductsForm, ProductsQuery } from '@/api/system/business/products/types';

/**
 * 查询充值商品列表
 * @param query
 * @returns {*}
 */

export const listProducts = (query?: ProductsQuery): AxiosPromise<ProductsVO[]> => {
  return request({
    url: '/business/products/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询充值商品详细
 * @param id
 */
export const getProducts = (id: string | number): AxiosPromise<ProductsVO> => {
  return request({
    url: '/business/products/' + id,
    method: 'get'
  });
};

/**
 * 新增充值商品
 * @param data
 */
export const addProducts = (data: ProductsForm) => {
  return request({
    url: '/business/products',
    method: 'post',
    data: data
  });
};

/**
 * 修改充值商品
 * @param data
 */
export const updateProducts = (data: ProductsForm) => {
  return request({
    url: '/business/products',
    method: 'put',
    data: data
  });
};

/**
 * 删除充值商品
 * @param id
 */
export const delProducts = (id: string | number | Array<string | number>) => {
  return request({
    url: '/business/products/' + id,
    method: 'delete'
  });
};
