2024-07-24 10:25:08 +02:00
|
|
|
package controllers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
|
|
|
|
oclib "cloud.o-forge.io/core/oc-lib"
|
|
|
|
beego "github.com/beego/beego/v2/server/web"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Operations about workflow
|
|
|
|
type WorkflowResourceController struct {
|
|
|
|
beego.Controller
|
|
|
|
}
|
|
|
|
|
2024-08-06 11:09:38 +02:00
|
|
|
// @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()
|
|
|
|
}
|
|
|
|
|
2024-07-24 10:25:08 +02:00
|
|
|
// @Title GetAll
|
|
|
|
// @Description find workflow by workflowid
|
|
|
|
// @Success 200 {workflow} models.workflow
|
|
|
|
// @router / [get]
|
|
|
|
func (o *WorkflowResourceController) GetAll() {
|
2024-08-06 11:09:38 +02:00
|
|
|
o.Data["json"] = oclib.LoadAll(oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE))
|
2024-07-24 10:25:08 +02:00
|
|
|
o.ServeJSON()
|
|
|
|
}
|
|
|
|
|
|
|
|
// @Title Update
|
|
|
|
// @Description create workflows
|
|
|
|
// @Param id path string true "the workflowid you want to get"
|
|
|
|
// @Param body body models.workflow true "The workflow content"
|
|
|
|
// @Success 200 {object} models.workflow
|
|
|
|
// @router /:id [put]
|
|
|
|
func (o *WorkflowResourceController) Put() {
|
|
|
|
// store and return Id or post with UUID
|
|
|
|
var res map[string]interface{}
|
|
|
|
id := o.Ctx.Input.Param(":id")
|
|
|
|
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
|
|
|
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE), res, id)
|
|
|
|
o.ServeJSON()
|
|
|
|
}
|
|
|
|
|
|
|
|
// @Title Create
|
|
|
|
// @Description create workflows
|
|
|
|
// @Param data body json true "body for data content (Json format)"
|
|
|
|
// @Success 200 {object} models.workflow
|
|
|
|
// @router / [post]
|
|
|
|
func (o *WorkflowResourceController) Post() {
|
|
|
|
var res map[string]interface{}
|
|
|
|
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
|
|
|
o.Data["json"] = oclib.StoreOne(oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE), res)
|
|
|
|
o.ServeJSON()
|
|
|
|
}
|
|
|
|
|
|
|
|
// @Title Get
|
|
|
|
// @Description find workflows
|
|
|
|
// @Param id path string true "the workflowid you want to get"
|
|
|
|
// @Success 200 {workflow} models.workflow
|
|
|
|
// @router /:id [get]
|
|
|
|
func (o *WorkflowResourceController) Get() {
|
|
|
|
id := o.Ctx.Input.Param(":id")
|
|
|
|
o.Data["json"] = oclib.LoadOne(oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE), id)
|
|
|
|
o.ServeJSON()
|
|
|
|
}
|
|
|
|
|
|
|
|
// @Title Delete
|
|
|
|
// @Description delete the workflow
|
|
|
|
// @Param id path string true "The workflowId you want to delete"
|
|
|
|
// @Success 200 {string} delete success!
|
|
|
|
// @router /:id [delete]
|
|
|
|
func (o *WorkflowResourceController) Delete() {
|
|
|
|
id := o.Ctx.Input.Param(":id")
|
|
|
|
o.Data["json"] = oclib.DeleteOne(oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE), id)
|
|
|
|
o.ServeJSON()
|
|
|
|
}
|