import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { XfDiscounttermVO, XfDiscounttermForm, XfDiscounttermQuery } from '@/api/consumption/xfDiscountterm/types';

/**
 * 查询折扣设备列表
 * @param query
 * @returns {*}
 */
export const listXfDiscountterm = (query?: XfDiscounttermQuery): AxiosPromise<XfDiscounttermVO[]> => {
  return request({
    url: '/backstage/consumption/xfDiscountterm/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询折扣设备详细
 * @param discountTermId
 */
export const getXfDiscountterm = (discountTermId: string | number): AxiosPromise<XfDiscounttermVO> => {
  return request({
    url: '/backstage/consumption/xfDiscountterm/' + discountTermId,
    method: 'get'
  });
};

/**
 * 新增折扣设备
 * @param data
 */
export const addXfDiscountterm = (data: XfDiscounttermForm) => {
  return request({
    url: '/backstage/consumption/xfDiscountterm',
    method: 'post',
    data: data
  });
};

/**
 * 批量新增折扣设备
 * @param data
 */
export const batchAddTerm = (data: number[]) => {
  return request({
    url: '/backstage/consumption/xfDiscountterm/batchAdd',
    method: 'post',
    data: data
  });
};

/**
 * 修改折扣设备
 * @param data
 */
export const updateXfDiscountterm = (data: XfDiscounttermForm) => {
  return request({
    url: '/backstage/consumption/xfDiscountterm',
    method: 'put',
    data: data
  });
};

/**
 * 删除折扣设备
 * @param discountTermId
 */
export const delXfDiscountterm = (discountTermId: string | number | Array<string | number>) => {
  return request({
    url: '/backstage/consumption/xfDiscountterm/' + discountTermId,
    method: 'delete'
  });
};
