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)