import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RulesVO, RulesForm, RulesQuery } from '@/api/system/rules/types';

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

export const listRules = (query?: RulesQuery): AxiosPromise<RulesVO[]> => {
  return request({
    url: '/system/rules/list',
    method: 'get',
    params: query
  });
};

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

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

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

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