Forráskód Böngészése

feat: 添加GetDataProcess函数

wangbo 2 hete
szülő
commit
238d5d4834
1 módosított fájl, 15 hozzáadás és 0 törlés
  1. 15 0
      ng_cws_client/callback_info.go

+ 15 - 0
ng_cws_client/callback_info.go

@@ -1,5 +1,10 @@
 package ng_cws_client
 
+import (
+	"encoding/json"
+	"fmt"
+)
+
 const (
 	EventTypeNodeAgree  = iota + 1 // 节点同意事件
 	EventTypeNodeReject            // 节点退回事件
@@ -45,3 +50,13 @@ type (
 		NodeContext            string `json:"nodeContext"`
 	}
 )
+
+func (ce CloudEvent) GetDataProcess() (*WorkflowEventDataProcess, error) {
+	dataProcess := new(WorkflowEventDataProcess)
+	err := json.Unmarshal(ce.Data, dataProcess)
+	if err != nil {
+		fmt.Println("流程回调转化json失败:", err)
+		return nil, err
+	}
+	return dataProcess, nil
+}