Acces to workflow execution

This commit is contained in:
mr
2024-08-06 11:09:38 +02:00
parent 4bb98f028b
commit 273fc878f7
11 changed files with 377 additions and 6 deletions

View File

@@ -12,6 +12,18 @@ type WorkflowController struct {
beego.Controller
}
// @Title Search
// @Description search workspace
// @Param search path string true "the word search you want to get"
// @Success 200 {workspace} models.workspace
// @router /search/:search [get]
func (o *WorkflowController) Search() {
// store and return Id or post with UUID
search := o.Ctx.Input.Param(":search")
o.Data["json"] = oclib.Search(nil, search, oclib.LibDataEnum(oclib.WORKFLOW))
o.ServeJSON()
}
// @Title Update
// @Description create workflows
// @Param id path string true "the workflowid you want to get"

View File

@@ -0,0 +1,56 @@
package controllers
import (
"time"
oclib "cloud.o-forge.io/core/oc-lib"
dbs "cloud.o-forge.io/core/oc-lib/dbs"
beego "github.com/beego/beego/v2/server/web"
"go.mongodb.org/mongo-driver/bson/primitive"
)
// Operations about workflow
type WorkflowExecutionController struct {
beego.Controller
}
// @Title Search
// @Description search workspace
// @Param start_date path string true "the word search you want to get"
// @Param end_date path string true "the word search you want to get"
// @Success 200 {workspace} models.workspace
// @router /search/:start_date/:end_date [get]
func (o *WorkflowExecutionController) Search() {
// store and return Id or post with UUID
start_date, _ := time.Parse("2006-01-02", o.Ctx.Input.Param(":start_date"))
end_date, _ := time.Parse("2006-01-02", o.Ctx.Input.Param(":end_date"))
sd := primitive.NewDateTimeFromTime(start_date)
ed := primitive.NewDateTimeFromTime(end_date)
f := dbs.Filters{
And: map[string][]dbs.Filter{
"execution_date": {{Operator: "gte", Value: sd}, {Operator: "lte", Value: ed}},
},
}
o.Data["json"] = oclib.Search(&f, "", oclib.LibDataEnum(oclib.WORKFLOW_EXECUTION))
o.ServeJSON()
}
// @Title GetAll
// @Description find workflow by workflowid
// @Success 200 {workflow} models.workflow
// @router / [get]
func (o *WorkflowExecutionController) GetAll() {
o.Data["json"] = oclib.LoadAll(oclib.LibDataEnum(oclib.WORKFLOW_EXECUTION))
o.ServeJSON()
}
// @Title Get
// @Description find workflow by workflowid
// @Param id path string true "the workflowid you want to get"
// @Success 200 {workflow} models.workflow
// @router /:id [get]
func (o *WorkflowExecutionController) Get() {
id := o.Ctx.Input.Param(":id")
o.Data["json"] = oclib.LoadOne(oclib.LibDataEnum(oclib.WORKFLOW_EXECUTION), id)
o.ServeJSON()
}

View File

@@ -12,12 +12,24 @@ type WorkflowResourceController struct {
beego.Controller
}
// @Title Search
// @Description search workspace
// @Param search path string true "the word search you want to get"
// @Success 200 {workspace} models.workspace
// @router /search/:search [get]
func (o *WorkflowResourceController) Search() {
// store and return Id or post with UUID
search := o.Ctx.Input.Param(":search")
o.Data["json"] = oclib.Search(nil, search, oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE))
o.ServeJSON()
}
// @Title GetAll
// @Description find workflow by workflowid
// @Success 200 {workflow} models.workflow
// @router / [get]
func (o *WorkflowResourceController) GetAll() {
o.Data["json"] = oclib.LoadAll(oclib.LibDataEnum(oclib.WORKFLOW))
o.Data["json"] = oclib.LoadAll(oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE))
o.ServeJSON()
}