import request from '@/utils/request'

/**
 * 根据ruleEngineId获取所有规则版本
 * @param ruleEngineId
 * @returns {AxiosPromise}
 */
export function getVersionList(ruleEngineId) {
  return request({
    url: '/rule/version/getVersionList?ruleEngineId='+ruleEngineId,
    method: 'get'
  })
}

/**
 * 插入规则版本
 * @param ruleVersion
 * @returns {AxiosPromise}
 */

export function insertRuleVersion(ruleVersion) {
  return request({
    url: '/rule/version/insertRuleVersion',
    method: 'post',
    data: ruleVersion
  })
}

/**
 * 生成详细规则版本
 * @param generateVersionClazzReq
 * @returns {AxiosPromise}
 */

export function generateClazz(generateVersionClazzReq) {
  return request({
    url: '/rule/version/generateClazz',
    method: 'post',
    data: generateVersionClazzReq
  })
}

/**
 * 激活/未激活 规则
 */
export function updateActivate(ruleEngineId,isActivate) {
  return request({
    url: '/rule/version/updateActivate?ruleEngineId='+ruleEngineId+"&isActivate="+isActivate,
    method: 'get'
  })
}

/**
 * 正常/停用状态
 */

export function updateVersionStatus(ruleEngineId,versionStatus) {
  return request({
    url: '/rule/version/updateVersionStatus?ruleEngineId='+ruleEngineId+"&versionStatus="+versionStatus,
    method: 'get'
  })
}

/**
 * 修改编译规则代码
 * @param ruleVersion
 * @returns {AxiosPromise}
 */
export function compiledCode(ruleVersion) {
  return request({
    url: '/rule/version/compiledCode',
    method: 'post',
    data: ruleVersion
  })
}
