规则增加验证不包含数据的情况,并再接口中同步增加json数据

This commit is contained in:
samwaf
2022-10-09 17:38:43 +08:00
parent 6c4627499f
commit a8517daad3
2 changed files with 4 additions and 1 deletions
+1
View File
@@ -6,6 +6,7 @@ type Rules struct {
Code string `json:"code"` //
Rulename string `json:"rulename"` //规则名称
Rulecontent string `json:"rulecontent"` //规则内容
RulecontentJSON string `json:"rulecontent_json"` //规则JSON内容
Ruleversionname string `json:"ruleversionname"` //规则版本名
Ruleversion int `json:"ruleversion"` //规则版本号
User_code string `json:"user_code"` //用户编码
+3 -1
View File
@@ -8,7 +8,9 @@ import (
func TestJsonTest(t *testing.T) {
// str 在项目开发中,是通过网络传输获取到.. 或者是读取文件获取到
str := "{\n \"rule_base\": {\n \"salience\": 10,\n \"rule_name\": \"试试\",\n \"rule_domain_code\": \"CODDD\"\n },\n \"rule_condition_detail\": {\n \"relation_detail\": [\n {\n \"fact_name\": \"MF\",\n \"attr\": \"StringAttribute\",\n \"attr_type\": \"string\",\n \"attr_judge\": \"==\",\n \"attr_val\": \"值\"\n },\n {\n \"fact_name\": \"MF\",\n \"attr\": \"IntAttribute\",\n \"attr_type\": \"int\",\n \"attr_judge\": \"==\",\n \"attr_val\": \"0\"\n }\n ],\n \"relation_symbol\": \"&&\"\n },\n \"rule_do_assignment\": [\n {\n \"fact_name\": \"MF\",\n \"attr\": \"StringAttribute\",\n \"attr_type\": \"string\",\n \"attr_val\": \"值\"\n },\n {\n \"fact_name\": \"MF\",\n \"attr\": \"IntAttribute\",\n \"attr_type\": \"int\",\n \"attr_val\": \"0\"\n }\n ],\n \"rule_do_method\": [\n {\n \"fact_name\": \"MF\",\n \"method_name\": \"DoSomeThing\",\n \"parms\": [\n {\n \"attr_type\": \"string\",\n \"attr_val\": \"值\"\n },\n {\n \"attr_type\": \"string\",\n \"attr_val\": \"值\"\n }\n ]\n }\n ]\n}"
//str := "{\n \"rule_base\": {\n \"salience\": 10,\n \"rule_name\": \"试试\",\n \"rule_domain_code\": \"CODDD\"\n },\n \"rule_condition_detail\": {\n \"relation_detail\": [\n {\n \"fact_name\": \"MF\",\n \"attr\": \"StringAttribute\",\n \"attr_type\": \"string\",\n \"attr_judge\": \"==\",\n \"attr_val\": \"值\"\n },\n {\n \"fact_name\": \"MF\",\n \"attr\": \"IntAttribute\",\n \"attr_type\": \"int\",\n \"attr_judge\": \"==\",\n \"attr_val\": \"0\"\n }\n ],\n \"relation_symbol\": \"&&\"\n },\n \"rule_do_assignment\": [\n {\n \"fact_name\": \"MF\",\n \"attr\": \"StringAttribute\",\n \"attr_type\": \"string\",\n \"attr_val\": \"值\"\n },\n {\n \"fact_name\": \"MF\",\n \"attr\": \"IntAttribute\",\n \"attr_type\": \"int\",\n \"attr_val\": \"0\"\n }\n ],\n \"rule_do_method\": [\n {\n \"fact_name\": \"MF\",\n \"method_name\": \"DoSomeThing\",\n \"parms\": [\n {\n \"attr_type\": \"string\",\n \"attr_val\": \"值\"\n },\n {\n \"attr_type\": \"string\",\n \"attr_val\": \"值\"\n }\n ]\n }\n ]\n}"
str := "{\n \"rule_base\": {\n \"salience\": 10,\n \"rule_name\": \"试试\",\n \"rule_domain_code\": \"CODDD\"\n },\n \"rule_condition_detail\": {\n \"relation_detail\": [\n {\n \"fact_name\": \"MF\",\n \"attr\": \"StringAttribute\",\n \"attr_type\": \"string\",\n \"attr_judge\": \"==\",\n \"attr_val\": \"值\"\n },\n {\n \"fact_name\": \"MF\",\n \"attr\": \"IntAttribute\",\n \"attr_type\": \"int\",\n \"attr_judge\": \"==\",\n \"attr_val\": \"0\"\n }\n ],\n \"relation_symbol\": \"&&\"\n },\n \"rule_do_assignment\": [\n \n ],\n \"rule_do_method\": [\n \n ]\n}"
var ruleTool rule.RuleTool
ruleInfo, err := ruleTool.LoadRule(str)