Discover Catalog Per
This commit is contained in:
@@ -2,8 +2,10 @@ package controllers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"oc-catalog/infrastructure"
|
||||
|
||||
oclib "cloud.o-forge.io/core/oc-lib"
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
@@ -13,6 +15,7 @@ type ProcessingController struct {
|
||||
}
|
||||
|
||||
var processing_collection = oclib.LibDataEnum(oclib.PROCESSING_RESOURCE)
|
||||
var processing_dt = tools.PROCESSING_RESOURCE
|
||||
|
||||
// @Title Update
|
||||
// @Description create processings
|
||||
@@ -26,7 +29,12 @@ func (o *ProcessingController) Put() {
|
||||
var res map[string]interface{}
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
||||
o.Data["json"] = oclib.NewRequest(processing_collection, user, peerID, groups, nil).UpdateOne(res, id)
|
||||
data := oclib.NewRequest(processing_collection, user, peerID, groups, nil).UpdateOne(res, id)
|
||||
if data.Err == "" {
|
||||
data, _ := json.Marshal(data.Data.Serialize(data.Data))
|
||||
infrastructure.Singleton.UpdatePublishEvent(o.Ctx.Request.Context(), &processing_dt, user, data)
|
||||
}
|
||||
o.Data["json"] = data
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@@ -39,7 +47,12 @@ func (o *ProcessingController) Post() {
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
var res map[string]interface{}
|
||||
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
||||
o.Data["json"] = oclib.NewRequest(processing_collection, user, peerID, groups, nil).StoreOne(res)
|
||||
data := oclib.NewRequest(processing_collection, user, peerID, groups, nil).StoreOne(res)
|
||||
if data.Err == "" {
|
||||
data, _ := json.Marshal(data.Data.Serialize(data.Data))
|
||||
infrastructure.Singleton.CreatePublishEvent(o.Ctx.Request.Context(), &processing_dt, user, data)
|
||||
}
|
||||
o.Data["json"] = data
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@@ -89,6 +102,34 @@ func (o *ProcessingController) Get() {
|
||||
func (o *ProcessingController) Delete() {
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
o.Data["json"] = oclib.NewRequest(processing_collection, user, peerID, groups, nil).DeleteOne(id)
|
||||
data := oclib.NewRequest(processing_collection, user, peerID, groups, nil).DeleteOne(id)
|
||||
if data.Err == "" {
|
||||
data, _ := json.Marshal(data.Data.Serialize(data.Data))
|
||||
infrastructure.Singleton.DeletePublishEvent(o.Ctx.Request.Context(), &processing_dt, user, data)
|
||||
}
|
||||
o.Data["json"] = data
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Search Decentralized
|
||||
// @Description find workflow by key word
|
||||
// @Param search path string true "the search you want to get"
|
||||
// @Param is_draft query string false "draft wished"
|
||||
// @Success 200 {workflow} models.workflow
|
||||
// @router /search/:search/decentralized/:type [get]
|
||||
func (o *ProcessingController) SearchDecentralized() {
|
||||
user, _, _ := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
search := o.Ctx.Input.Param(":search")
|
||||
t := o.Ctx.Input.Param(":type")
|
||||
err := infrastructure.Singleton.SearchPublishEvent(o.Ctx.Request.Context(), &processing_dt, t, user, search)
|
||||
if err != nil {
|
||||
o.Data["json"] = map[string]interface{}{
|
||||
"data": nil,
|
||||
"code": 400,
|
||||
"error": err,
|
||||
}
|
||||
o.ServeJSON()
|
||||
return
|
||||
}
|
||||
Websocket(o.Ctx.Request.Context(), user, o.Ctx.ResponseWriter, o.Ctx.Request)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user