Bläddra i källkod

feat: 添加同步

double.huang 5 år sedan
förälder
incheckning
dcfefa3b2d

+ 5 - 1
controllers/gen/SysWfController_gen.go

@@ -124,11 +124,15 @@ func (c *SysWfController) Recall(ctx *gin.Context) {
 }
 
 func (c *SysWfController) Interrupt(ctx *gin.Context) {
-	//
 	db := c.apiengine.BusinessOrmEngine[ctx.GetString("domain")]
 	partial.SysWf_Interrupt(&entitys.CtrlContext{c.apiengine, ctx, db, c.apiengine.PlatformOrmEngine})
 }
 
+func (c *SysWfController) RepairSync(ctx *gin.Context) {
+	db := c.apiengine.BusinessOrmEngine[ctx.GetString("domain")]
+	partial.SysWf_RepairSync(&entitys.CtrlContext{c.apiengine, ctx, db, c.apiengine.PlatformOrmEngine})
+}
+
 // Designer
 // @Title Designer
 // @Description 修改流程定义

+ 22 - 0
controllers/partial/SysWfController.go

@@ -210,6 +210,28 @@ func SysWf_Interrupt(c *entitys.CtrlContext) {
 	}
 }
 
+// _Interrupt
+// @Title _Interrupt
+// @Description 终止
+// @Param	instance_id      false  ""
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+func SysWf_RepairSync(c *entitys.CtrlContext) {
+	obj := map[string]interface{}{}
+	err := c.Ctx.Bind(&obj)
+	if err != nil {
+		c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
+		return
+	}
+	instanceId := fmt.Sprintf("%v", obj["instance_id"])
+	bytess, err := wfclient.NewWFClient(c).RepairSync(instanceId, obj, c)
+	if err == nil {
+		c.Ctx.JSON(200, sysmodel.SysReturn{200, "", string(bytess)})
+	} else {
+		c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
+	}
+}
+
 // _Designer
 // @Title _Designer
 // @Description 修改流程定义

+ 3 - 0
routers/sys_wf_gen.go

@@ -43,6 +43,9 @@ func registerSysWfRouter(e *engine.ApiEngine) {
 	//v1.GET("/recall",ctrler.Recall)
 	v1.POST("/interrupt", ctrler.Interrupt)
 
+	//v1.GET("/recall",ctrler.Recall)
+	v1.POST("/repair", ctrler.RepairSync)
+
 	//v1.GET("/newstep",ctrler.Recall)
 	v1.POST("/newstep", ctrler.NewStep)
 

+ 29 - 0
wfclient/client.go

@@ -535,6 +535,35 @@ func (w *WFClient) Interrupt(definedId string, formData map[string]interface{},
 	return bytess, err
 }
 
+//同步修复回调
+func (w *WFClient) RepairSync(definedId string, formData map[string]interface{}, c *entitys.CtrlContext) ([]byte, error) {
+	var RunRespInfo struct {
+		DefineId      string      `json:"define_id"`
+		InstanceId    string      `json:"instance_id"`
+		DefineName    string      `json:"define_name"`
+		InstanceName  string      `json:"instance_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"`
+	}
+	callWFCallback("repairSync", &CallbackArg{
+		DefineId:     RunRespInfo.DefineId,
+		InstanceId:   definedId,
+		DefineName:   RunRespInfo.DefineName,
+		InstanceName: RunRespInfo.InstanceName,
+		FormData:     formData["form_data"].(string),
+		Executor:     RunRespInfo.Executor,
+		UserId:       w.userId,
+		Context:      c,
+	})
+	return []byte{}, nil
+}
+
 //撤回
 func (w *WFClient) Delete(definedId string) ([]byte, error) {
 	url := w.getFullUrl("/api/wf_define/delete")