From a8517daad36992d881c3f49f39ef9bd58ec24522 Mon Sep 17 00:00:00 2001 From: samwaf Date: Sun, 9 Oct 2022 17:38:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=84=E5=88=99=E5=A2=9E=E5=8A=A0=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E4=B8=8D=E5=8C=85=E5=90=AB=E6=95=B0=E6=8D=AE=E7=9A=84?= =?UTF-8?q?=E6=83=85=E5=86=B5=EF=BC=8C=E5=B9=B6=E5=86=8D=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=B8=AD=E5=90=8C=E6=AD=A5=E5=A2=9E=E5=8A=A0json=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/rules.go | 1 + test/ruleinfotest_test.go | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/model/rules.go b/model/rules.go index f98e644..02490cd 100644 --- a/model/rules.go +++ b/model/rules.go @@ -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"` //用户编码 diff --git a/test/ruleinfotest_test.go b/test/ruleinfotest_test.go index 73bf786..cf3b8cc 100644 --- a/test/ruleinfotest_test.go +++ b/test/ruleinfotest_test.go @@ -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)