瀏覽代碼

fix: newstep

double.huang 5 年之前
父節點
當前提交
1a82faa97d
共有 4 個文件被更改,包括 75 次插入0 次删除
  1. 13 0
      controllers/gen/SysWfController_gen.go
  2. 26 0
      controllers/partial/SysWfController.go
  3. 3 0
      routers/sys_wf_gen.go
  4. 33 0
      wfclient/client.go

+ 13 - 0
controllers/gen/SysWfController_gen.go

@@ -71,6 +71,19 @@ func (c *SysWfController) Run(ctx *gin.Context) {
 	partial.SysWf_Run(&entitys.CtrlContext{c.apiengine, ctx, db, c.apiengine.PlatformOrmEngine})
 }
 
+// Run
+// @Title Run
+// @Description 运行实例
+// @Param	      false  ""
+// @Success 200 {object} sysReturn
+// @Failure 403 :id is empty
+// @router /run  [post]
+func (c *SysWfController) NewStep(ctx *gin.Context) {
+	//
+	db := c.apiengine.BusinessOrmEngine[ctx.GetString("domain")]
+	partial.SysWf_NewStep(&entitys.CtrlContext{c.apiengine, ctx, db, c.apiengine.PlatformOrmEngine})
+}
+
 // WfDefinesTag
 // @Title WfDefinesTag
 // @Description 根据tag获取工作流事项

+ 26 - 0
controllers/partial/SysWfController.go

@@ -105,6 +105,32 @@ func SysWf_Run(c *entitys.CtrlContext) {
 	}
 }
 
+// _NewStep
+// @Title _NewStep
+// @Description 创建步骤
+// @Param	choice      false  ""
+// @Param	instance_id      false  ""
+// @Param	nextStep      false  ""
+// @Param	option      false  ""
+// @Param	users      false  ""
+// @Success 200 {object} models.Account
+// @Failure 403 :id is empty
+func SysWf_NewStep(c *entitys.CtrlContext) {
+	obj := models.WfRunData{}
+	err := c.Ctx.Bind(&obj)
+	if err != nil {
+		c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
+		return
+	}
+
+	bytess, err := wfclient.NewWFClient(c).NewStep(obj.InstanceId, obj.Users, obj.Choice, obj.Opinion, obj.NextStep, c)
+	if err == nil {
+		c.Ctx.JSON(200, sysmodel.SysReturn{200, "", string(bytess)})
+	} else {
+		c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
+	}
+}
+
 // _WfDefinesTag
 // @Title _WfDefinesTag
 // @Description 根据tag获取工作流事项

+ 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("/newstep",ctrler.Recall)
+	v1.POST("/newstep", ctrler.NewStep)
+
 	v1.GET("/designer", ctrler.Designer)
 	//v1.POST("/designer",ctrler.Designer)
 

+ 33 - 0
wfclient/client.go

@@ -299,6 +299,39 @@ func (w *WFClient) Run(instanceId, userId, choice, options, nextStep string, c *
 	return []byte{}, nil
 }
 
+/**
+ * @brief: run the wf instance
+ * @param1 instanceId: id of instance
+ * @param2 userId: approver id
+ * @param3 choice: choice
+ * @param4 options: options
+ * @return1 content of response
+ * @return2 error
+ */
+func (w *WFClient) NewStep(instanceId, userId, choice, options, nextStep string, c *entitys.CtrlContext) ([]byte, error) {
+	url := w.getFullUrl("api/wf_instance/newstep")
+
+	params := make(map[string]string)
+	params["instance_id"] = instanceId
+	params["users"] = userId
+	if choice != "" {
+		params["choice"] = choice
+	}
+	if options != "" {
+		params["opinion"] = options
+	}
+	if nextStep != "" {
+		params["nextStep"] = nextStep
+	}
+
+	bytess, err := HttpClientInstance().post(url, params, nil)
+	if err != nil {
+		return nil, err
+	}
+
+	return bytess, err
+}
+
 /**
  * @brief: pre the wf instance
  * @param1 instanceId: id of instance