基于模版格式的代码,看着会比较清晰,所以添加了一个新的配置参数template 可以开启此选项
参考配置
easyrules:
skipOnFirstAppliedRule: false
skipOnFirstNonTriggeredRule: false
priorityThreshold: 1000000
project: demo
repo: demo
contentType: json
confName: /rules3.json
template: true
centraldogma:
hosts:
- "127.0.0.1:36462"
server:
port: 9000
rule 配置说明
需要使用#{} 格式,因为easy rules 默认会讲facts 对象的内容转为map,我们可以使用#进行变量引用,以下是参考配置
[
{
"rulesId": "demoapp",
"rulesContent": [
{
"name": "demo",
"description": "mydemo",
"priority": 1,
"compositeRuleType": "UnitRuleGroup",
"composingRules": [
{
"name": "first",
"description": "first rule",
"condition": "#{#biz.age>100}",
"priority": 2,
"actions": [
"#{@myService.setInfo(#biz)}" // @ 引用spring bean # 引用变量
]
}
]
}
]
}
]