浏览代码

修改wfclient

huangyh 6 年之前
父节点
当前提交
783ec21e8a
共有 1 个文件被更改,包括 19 次插入19 次删除
  1. 19 19
      wfclient/client.go

+ 19 - 19
wfclient/client.go

@@ -6,6 +6,7 @@ import (
 	"encoding/xml"
 	"errors"
 	"fmt"
+	"git.qianqiusoft.com/qianqiusoft/light-apiengine/entitys"
 	"git.qianqiusoft.com/qianqiusoft/light-apiengine/utils"
 	"net/http"
 	"strconv"
@@ -31,6 +32,7 @@ type CallbackArg struct {
 	Choice     string
 	Executor   string
 	UserId     string
+	Context    *entitys.CtrlContext
 }
 
 type WFClient struct {
@@ -218,7 +220,7 @@ type Condition struct {
  * @return1 content of response
  * @return2 error
  */
-func (w *WFClient) Run(instanceId, userId, choice, options, nextStep string) ([]byte, error) {
+func (w *WFClient) Run(instanceId, userId, choice, options, nextStep string, c *entitys.CtrlContext) ([]byte, error) {
 	url := w.getFullUrl("api/wf_instance/run")
 
 	params := make(map[string]string)
@@ -235,17 +237,17 @@ func (w *WFClient) Run(instanceId, userId, choice, options, nextStep string) ([]
 	}
 
 	var RunRespInfo struct {
-		DefineId      string        `json:"define_id"`
-		InstanceId    string        `json:"instance_id"`
-		DefineName    string        `json:"define_name"`
-		Choices       []*Choice     `json:"choices"`
-		Transition    []*Transition `json:"transition"`
-		StepType      string        `json:"step_type"`
-		FormData      string        `json:"form_data"`
-		StepName      string        `json:"step_name"`
-		ActorType     string        `json:"actor_type"`
-		Executor      string        `json:"executor"`
-		StartCallback string        `json:"start_callback"`
+		DefineId      string      `json:"define_id"`
+		InstanceId    string      `json:"instance_id"`
+		DefineName    string      `json:"define_name"`
+		Choices       []*Choice   `json:"choices"`
+		Transition    *Transition `json:"transition"`
+		StepType      string      `json:"step_type"`
+		FormData      string      `json:"form_data"`
+		StepName      string      `json:"step_name"`
+		ActorType     string      `json:"actor_type"`
+		Executor      string      `json:"executor"`
+		StartCallback string      `json:"start_callback"`
 	}
 
 	bytess, err := HttpClientInstance().post(url, params, nil)
@@ -268,12 +270,13 @@ func (w *WFClient) Run(instanceId, userId, choice, options, nextStep string) ([]
 			fmt.Println("------------------------------------->121")
 			callback(CallbackArg{
 				DefineId:   RunRespInfo.DefineId,
-				InstanceId: RunRespInfo.InstanceId,
+				InstanceId: instanceId,
 				DefineName: RunRespInfo.DefineName,
 				FormData:   RunRespInfo.FormData,
 				Choice:     choice,
 				Executor:   RunRespInfo.Executor,
 				UserId:     w.userId,
+				Context:    c,
 			})
 		}
 	}
@@ -281,11 +284,7 @@ func (w *WFClient) Run(instanceId, userId, choice, options, nextStep string) ([]
 	// 连线回调
 	linkCallbacks := []string{}
 	if RunRespInfo.StepType == "begin" || RunRespInfo.StepType == "normal" {
-		for _, c := range RunRespInfo.Transition {
-			if c.Name == choice {
-				linkCallbacks = strings.Split(c.Callback, ",")
-			}
-		}
+		linkCallbacks = strings.Split(RunRespInfo.Transition.Callback, ",")
 	} else {
 		for _, c := range RunRespInfo.Choices {
 			if c.Name == choice {
@@ -299,12 +298,13 @@ func (w *WFClient) Run(instanceId, userId, choice, options, nextStep string) ([]
 		if ok {
 			callback(CallbackArg{
 				DefineId:   RunRespInfo.DefineId,
-				InstanceId: RunRespInfo.InstanceId,
+				InstanceId: instanceId,
 				DefineName: RunRespInfo.DefineName,
 				FormData:   RunRespInfo.FormData,
 				Choice:     choice,
 				Executor:   RunRespInfo.Executor,
 				UserId:     w.userId,
+				Context:    c,
 			})
 		}
 	}