38 lines
1.3 KiB
Go
38 lines
1.3 KiB
Go
package flow_definition
|
|
|
|
import (
|
|
"approveflow/app/http/base"
|
|
"approveflow/app/provider/flow_definition"
|
|
"approveflow/app/utils"
|
|
"github.com/Superdanda/hade/framework/gin"
|
|
"net/http"
|
|
)
|
|
|
|
type flowDefinitionSaveParam struct {
|
|
Name string `json:"name"` // 流程名称
|
|
Description string `json:"description"` // 流程描述
|
|
}
|
|
|
|
// DefinitionSave 保存流程定义
|
|
// @Summary 保存新的流程定义
|
|
// @Description 创建一个新的流程定义
|
|
// @ID flow-definition-save
|
|
// @Tags flow-definition
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param flowDefinitionSaveParam body flowDefinitionSaveParam true "流程定义保存请求参数"
|
|
// @Success 200 {object} base.Result "返回成功信息"
|
|
// @Failure 500 {object} base.Result "操作失败"
|
|
// @Router /definition/save [post]
|
|
func (a *FlowDefinitionApi) DefinitionSave(context *gin.Context) {
|
|
param := utils.QuickBind[flowDefinitionSaveParam](context)
|
|
definitionService := context.MustMake(flow_definition.FlowDefinitionKey).(flow_definition.Service)
|
|
approvalFlow := flow_definition.NewApprovalFlow(param.Name, param.Description)
|
|
err := definitionService.CreateFlow(context, approvalFlow)
|
|
if err != nil {
|
|
context.ISetStatus(http.StatusInternalServerError).IJson(base.Fail("操作失败"))
|
|
return
|
|
}
|
|
context.ISetOkStatus().IJson(base.SuccessWithOKMessage())
|
|
}
|