import request from '@/utils/request'

// 查询规则版本列表
export function listRuleVersion(data) {
  return request({
    url: '/engine/ruleVersion/list',
    method: 'post',
    params: {pageNum: data.pageNum, pageSize: data.pageSize},
    data
  })
}

// 查询规则版本详细
export function getRuleVersion(id) {
  return request({
    url: '/engine/ruleVersion/' + id,
    method: 'get'
  })
}

// 新增规则版本
export function addRuleVersion(data) {
  return request({
    url: '/engine/ruleVersion',
    method: 'post',
    data: data
  })
}

// 修改规则版本
export function updateRuleVersion(data) {
  return request({
    url: '/engine/ruleVersion',
    method: 'put',
    data: data
  })
}

// 删除规则版本
export function delRuleVersion(id) {
  return request({
    url: '/engine/ruleVersion/' + id,
    method: 'delete'
  })
}

//存储代码
export function writeFile(data) {
  return request({
    url: '/engine/ruleVersion/writeFile',
    method: 'post',
    data
  })
}

//查询代码
export function readFile(fileName) {
  return request({
    url: `/engine/ruleVersion/readFile/${fileName}`,
    method: 'post'
  })
}

//库表二级联动
export function getTableInfoList() {
  return request({
    url: '/engine/ruleVersion/dataSource/tableInfo',
    method: 'get',
  })
}

//库表二级联动
export function getDataAnalysis(id) {
  return request({
    url: `/engine/ruleVersion/dataSource/table/${id}`,
    method: 'get',
  })
}

//获取KTLV数据
export function getEtlTableData(data) {
  return request({
    url: `/engine/ruleVersion/getEtlTableData`,
    method: 'post',
    data
  })
}

//测试值
export function execution(data) {
  return request({
    url: `/engine/ruleVersion/execution/${data.engineKey}`,
    method: 'post',
    data
  })
}

//测试行
export function lineFile(data) {
  return request({
    url: `/engine/ruleVersion/lineFile/${data.ruleVersionClass}`,
    method: 'post',
    data: data.data
  })
}

//测试组
export function groupFile(data) {
  return request({
    url: `/engine/ruleVersion/groupFile/${data.ruleVersionClass}`,
    method: 'post',
    data: data.data
  })
}
//判断类是否已存在
export function isClassExist(val) {
  return request({
    url: `/engine/ruleVersion/isClassExist/${val}`,
    method: 'get',
  })
}


