working oc-catalog + enum ref
This commit is contained in:
@@ -12,6 +12,8 @@ type ProcessingController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
var processing_collection = oclib.LibDataEnum(oclib.PROCESSING_RESOURCE)
|
||||
|
||||
// @Title Update
|
||||
// @Description create processings
|
||||
// @Param id path string true "the processing id you want to get"
|
||||
@@ -20,10 +22,11 @@ type ProcessingController struct {
|
||||
// @router /:id [put]
|
||||
func (o *ProcessingController) Put() {
|
||||
// store and return Id or post with UUID
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
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.PROCESSING_RESOURCE), res, id)
|
||||
o.Data["json"] = oclib.NewRequest(processing_collection, user, peerID, groups, nil).UpdateOne(res, id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@@ -33,29 +36,36 @@ func (o *ProcessingController) Put() {
|
||||
// @Success 200 {processing} models.processing
|
||||
// @router / [post]
|
||||
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.StoreOne(oclib.LibDataEnum(oclib.PROCESSING_RESOURCE), res)
|
||||
o.Data["json"] = oclib.NewRequest(processing_collection, user, peerID, groups, nil).StoreOne(res)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title GetAll
|
||||
// @Description find processing by id
|
||||
// @Param is_draft query string false "draft wished"
|
||||
// @Success 200 {processing} models.processing
|
||||
// @router / [get]
|
||||
func (o *ProcessingController) GetAll() {
|
||||
o.Data["json"] = oclib.LoadAll(oclib.LibDataEnum(oclib.PROCESSING_RESOURCE))
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
isDraft := o.Ctx.Input.Query("is_draft")
|
||||
o.Data["json"] = oclib.NewRequest(processing_collection, user, peerID, groups, nil).LoadAll(isDraft == "true")
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Get
|
||||
// @Description find processing by key word
|
||||
// @Param search path string true "the search you want to get"
|
||||
// @Param is_draft query string false "draft wished"
|
||||
// @Success 200 {processing} models.processing
|
||||
// @router /search/:search [get]
|
||||
func (o *ProcessingController) Search() {
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
search := o.Ctx.Input.Param(":search")
|
||||
o.Data["json"] = oclib.Search(nil, search, oclib.LibDataEnum(oclib.PROCESSING_RESOURCE))
|
||||
isDraft := o.Ctx.Input.Query("is_draft")
|
||||
o.Data["json"] = oclib.NewRequest(processing_collection, user, peerID, groups, nil).Search(nil, search, isDraft == "true")
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@@ -65,8 +75,9 @@ func (o *ProcessingController) Search() {
|
||||
// @Success 200 {processing} models.processing
|
||||
// @router /:id [get]
|
||||
func (o *ProcessingController) Get() {
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
o.Data["json"] = oclib.LoadOne(oclib.LibDataEnum(oclib.PROCESSING_RESOURCE), id)
|
||||
o.Data["json"] = oclib.NewRequest(processing_collection, user, peerID, groups, nil).LoadOne(id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@@ -76,7 +87,8 @@ func (o *ProcessingController) Get() {
|
||||
// @Success 200 {processing} delete success!
|
||||
// @router /:id [delete]
|
||||
func (o *ProcessingController) Delete() {
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
o.Data["json"] = oclib.DeleteOne(oclib.LibDataEnum(oclib.PROCESSING_RESOURCE), id)
|
||||
o.Data["json"] = oclib.NewRequest(processing_collection, user, peerID, groups, nil).DeleteOne(id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user