mirror of
https://github.com/usual2970/certimate.git
synced 2025-07-29 05:34:28 +00:00
fix conflict
This commit is contained in:
39
internal/rest/workflow.go
Normal file
39
internal/rest/workflow.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package rest
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/labstack/echo/v5"
|
||||
"github.com/usual2970/certimate/internal/domain"
|
||||
"github.com/usual2970/certimate/internal/utils/resp"
|
||||
)
|
||||
|
||||
type WorkflowService interface {
|
||||
Run(ctx context.Context, req *domain.WorkflowRunReq) error
|
||||
}
|
||||
|
||||
type workflowHandler struct {
|
||||
service WorkflowService
|
||||
}
|
||||
|
||||
func NewWorkflowHandler(route *echo.Group, service WorkflowService) {
|
||||
handler := &workflowHandler{
|
||||
service: service,
|
||||
}
|
||||
|
||||
group := route.Group("/workflow")
|
||||
|
||||
group.POST("/run", handler.run)
|
||||
}
|
||||
|
||||
func (handler *workflowHandler) run(c echo.Context) error {
|
||||
req := &domain.WorkflowRunReq{}
|
||||
if err := c.Bind(req); err != nil {
|
||||
return resp.Err(c, err)
|
||||
}
|
||||
|
||||
if err := handler.service.Run(c.Request().Context(), req); err != nil {
|
||||
return resp.Err(c, err)
|
||||
}
|
||||
return resp.Succ(c, nil)
|
||||
}
|
Reference in New Issue
Block a user