import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { XfTermVO, XfTermForm, XfTermQuery, XfTermParamVo } from '@/api/consumption/xfTerm/types';

/**
 * 查询消费设备列表
 * @param query
 * @returns {*}
 */
export const listXfTerm = (query?: XfTermQuery): AxiosPromise<XfTermVO[]> => {
  return request({
    url: '/backstage/consumption/xfTerm/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询消费设备详细
 * @param termId
 */
export const getXfTerm = (termId: string | number): AxiosPromise<XfTermVO> => {
  return request({
    url: '/backstage/consumption/xfTerm/' + termId,
    method: 'get'
  });
};
export const getXfTermParam = (termId: string | number): AxiosPromise<XfTermParamVo> => {
  return request({
    url: '/backstage/consumption/xfTerm/param/' + termId,
    method: 'get'
  });
};

/**
 * 新增消费设备
 * @param data
 */
export const addXfTerm = (data: XfTermForm) => {
  return request({
    url: '/backstage/consumption/xfTerm',
    method: 'post',
    data: data
  });
};

/**
 * 修改消费设备
 * @param data
 */
export const updateXfTerm = (data: XfTermForm) => {
  return request({
    url: '/backstage/consumption/xfTerm',
    method: 'put',
    data: data
  });
};
export const updateXfTermParam = (data: XfTermForm) => {
  return request({
    url: '/backstage/consumption/xfTerm/updateParam',
    method: 'post',
    data: data
  });
};

/**
 * 删除消费设备
 * @param termId
 */
export const delXfTerm = (termId: string | number | Array<string | number>) => {
  return request({
    url: '/backstage/consumption/xfTerm/' + termId,
    method: 'delete'
  });
};
/**
 * 查询消费设备列表
 * @param query
 * @returns {*}
 */
export const listAllXfTerm = (query?: XfTermQuery): AxiosPromise<XfTermVO[]> => {
  return request({
    url: '/backstage/consumption/xfTerm/all',
    method: 'get',
    params: query
  });
};
