import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { XfLimitedtermVO, XfLimitedtermForm, XfLimitedtermQuery } from '@/api/consumption/xfLimitedterm/types';

/**
 * 查询限次设备绑定列表
 * @param query
 * @returns {*}
 */
export const listXfLimitedterm = (query?: XfLimitedtermQuery): AxiosPromise<XfLimitedtermVO[]> => {
  return request({
    url: '/backstage/consumption/xfLimitedterm/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询限次设备绑定详细
 * @param limitedTermId
 */
export const getXfLimitedterm = (limitedTermId: string | number): AxiosPromise<XfLimitedtermVO> => {
  return request({
    url: '/backstage/consumption/xfLimitedterm/' + limitedTermId,
    method: 'get'
  });
};

/**
 * 新增限次设备绑定
 * @param data
 */
export const addXfLimitedterm = (data: XfLimitedtermForm) => {
  return request({
    url: '/backstage/consumption/xfLimitedterm',
    method: 'post',
    data: data
  });
};

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

/**
 * 修改限次设备绑定
 * @param data
 */
export const updateXfLimitedterm = (data: XfLimitedtermForm) => {
  return request({
    url: '/backstage/consumption/xfLimitedterm',
    method: 'put',
    data: data
  });
};

/**
 * 删除限次设备绑定
 * @param limitedTermId
 */
export const delXfLimitedterm = (limitedTermId: string | number | Array<string | number>) => {
  return request({
    url: '/backstage/consumption/xfLimitedterm/' + limitedTermId,
    method: 'delete'
  });
};
