规则引擎

This commit is contained in:
PandaGoAdmin
2023-03-01 16:55:47 +08:00
parent 8e854ce527
commit 1be2dc7537
53 changed files with 1104 additions and 418 deletions

View File

@@ -12,9 +12,10 @@ type Node struct {
}
type Edge struct {
SourceNodeId string `json:"sourceNodeId" yaml:"sourceNodeId"`
TargetNodeId string `json:"targetNodeId" yaml:"targetNodeId"`
Type string `json:"type" yaml:"type"` //success or fail
SourceNodeId string `json:"sourceNodeId" yaml:"sourceNodeId"`
TargetNodeId string `json:"targetNodeId" yaml:"targetNodeId"`
Type string `json:"type" yaml:"type"` //success or fail
Properties map[string]interface{} `json:"properties" yaml:"properties"` //debugMode
}
type Manifest struct {
@@ -26,12 +27,13 @@ type Manifest struct {
func New(data []byte) (*Manifest, error) {
firstRuleNodeId := ""
manifest := make(map[string]interface{})
if err := json.Unmarshal(data, manifest); err != nil {
if err := json.Unmarshal(data, &manifest); err != nil {
logrus.WithError(err).Errorf("invalid node chain manifest file")
return nil, err
}
nodes := make([]Node, 0)
for _, node := range manifest["nodes"].([]map[string]interface{}) {
for _, mn := range manifest["nodes"].([]interface{}) {
node := mn.(map[string]interface{})
if node["type"].(string) == "InputNode" {
firstRuleNodeId = node["id"].(string)
}
@@ -42,9 +44,11 @@ func New(data []byte) (*Manifest, error) {
})
}
edges := make([]Edge, 0)
for _, edge := range manifest["edges"].([]map[string]interface{}) {
for _, en := range manifest["edges"].([]interface{}) {
edge := en.(map[string]interface{})
edges = append(edges, Edge{
Type: edge["type"].(string),
Properties: edge["properties"].(map[string]interface{}),
SourceNodeId: edge["sourceNodeId"].(string),
TargetNodeId: edge["targetNodeId"].(string),
})

View File

@@ -7,8 +7,7 @@
"y": 280,
"properties": {
"icon": "/src/assets/icon_module/svg/start.svg",
"debugMode": false,
"status": false
"debugMode": false
},
"zIndex": 1002,
"text": {
@@ -24,8 +23,7 @@
"y": 160,
"properties": {
"icon": "/src/assets/icon_module/svg/function.svg",
"debugMode": false,
"status": false
"debugMode": false
},
"zIndex": 1004,
"text": {
@@ -42,7 +40,7 @@
"properties": {
"icon": "/src/assets/icon_module/svg/switch.svg",
"debugMode": false,
"status": false
"scripts": "return {\n msg: msg,\n metadata: metadata,\n msgType: msgType\n};"
},
"zIndex": 1006,
"text": {
@@ -66,7 +64,9 @@
"x": 540,
"y": 160
},
"properties": {},
"properties": {
"type": "Success"
},
"zIndex": 1007,
"pointsList": [
{
@@ -100,7 +100,9 @@
"x": 540,
"y": 460
},
"properties": {},
"properties": {
"type": "Failure"
},
"zIndex": 1008,
"pointsList": [
{