approveflow/app/http/module/flow_instance/api_instances_start.go

35 lines
1011 B
Go

package flow_instance
import (
"approveflow/app/http/base/res"
"approveflow/app/provider/flow_instance"
"approveflow/app/utils"
"github.com/Superdanda/hade/framework/gin"
)
type InstancesStartParam struct {
InstanceID int64 `json:"instance_id"`
}
// InstancesStart handler
// @Summary 启动审批流
// @Description 启动审批流
// @ID instances-start
// @Tags flow-instances
// @Accept json
// @Produce json
// @Param InstancesStartParam body InstancesStartParam true "启动实例ID"
// @Success 200 {object} base.Result "返回成功的流程定义数据"
// @Failure 500 {object} base.Result "返回失败的流程定义数据"
// @Router /instances/start [post]
func (api *FlowInstanceApi) InstancesStart(c *gin.Context) {
param := utils.QuickBind[InstancesStartParam](c)
instanceService := c.MustMake(flow_instance.FlowInstanceKey).(flow_instance.Service)
_, err := instanceService.StartInstance(c, param.InstanceID)
if err != nil {
res.FailWithErr(c, err)
return
}
res.Success(c)
}