import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RuleConfigVO, RuleConfigForm, RuleConfigQuery } from '@/api/system/ruleConfig/types';

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

export const listRuleConfig = (query?: RuleConfigQuery): AxiosPromise<{records: RuleConfigVO[]}> => {
  return request({
    url: '/system-rule-module-config/list',
    method: 'post',
    data: query
  });
};

/**
 * 查询规则配置详细
 * @param id
 */
export const getRuleConfig = (data): AxiosPromise<RuleConfigVO> => {
  return request({
    url: '/system-rule-module-config/get-by-id',
    method: 'POST',
    data
  });
};

/**
 * 新增/修改规则配置
 * @param data
 */
export const addRuleConfig = (data: RuleConfigForm) => {
  return request({
    url: '/system-rule-module-config/save',
    method: 'post',
    data: data
  });
};


/**
 * 删除规则配置
 * @param id
 */
export const delRuleConfig = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system-rule-module-config/delete',
    method: 'POST',
    data: {id}
  });
};

/**
 * 字段配置
 * @param resourceType
 */
export const getRuleField = (resourceType: string | number | Array<string | number>) => {
  return request({
    url: '/system-rule-module-config/getRuleField',
    method: 'POST',
    data: {resourceType}
  });
};
