import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RulesNodeVO, RulesNodeForm, RulesNodeQuery } from '@/api/system/rulesNode/types';

/**
 * 查询规则节点列表
 * @param query
 * @returns {*}
 */

export const listRulesNode = (query?: RulesNodeQuery): AxiosPromise<RulesNodeVO[]> => {
  return request({
    url: '/system/rulesNode/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询规则节点详细
 * @param id
 */
export const getRulesNode = (id: string | number): AxiosPromise<RulesNodeVO> => {
  return request({
    url: '/system/rulesNode/' + id,
    method: 'get'
  });
};

/**
 * 新增规则节点
 * @param data
 */
export const addRulesNode = (data: RulesNodeForm) => {
  return request({
    url: '/system/rulesNode',
    method: 'post',
    data: data
  });
};

/**
 * 修改规则节点
 * @param data
 */
export const updateRulesNode = (data: RulesNodeForm) => {
  return request({
    url: '/system/rulesNode',
    method: 'put',
    data: data
  });
};

/**
 * 删除规则节点
 * @param id
 */
export const delRulesNode = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/rulesNode/' + id,
    method: 'delete'
  });
};
