package controllers import ( "encoding/json" oclib "cloud.o-forge.io/core/oc-lib" beego "github.com/beego/beego/v2/server/web" ) // Operations about data type ProcessingController struct { beego.Controller } // @Title Update // @Description create processings // @Param id path string true "the processing id you want to get" // @Param body body models.processing true "The processing content" // @Success 200 {processing} models.processing // @router /:id [put] func (o *ProcessingController) 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.PROCESSING_RESOURCE), res, id) o.ServeJSON() } // @Title Create // @Description create processing // @Param processing body json true "body for processing content (Json format)" // @Success 200 {processing} models.processing // @router / [post] func (o *ProcessingController) Post() { 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.ServeJSON() } // @Title GetAll // @Description find processing by id // @Success 200 {processing} models.processing // @router / [get] func (o *ProcessingController) GetAll() { o.Data["json"] = oclib.LoadAll(oclib.LibDataEnum(oclib.PROCESSING_RESOURCE)) o.ServeJSON() } // @Title Get // @Description find processing by id // @Param id path string true "the id you want to get" // @Success 200 {processing} models.processing // @router /:id [get] func (o *ProcessingController) Get() { id := o.Ctx.Input.Param(":id") o.Data["json"] = oclib.LoadOne(oclib.LibDataEnum(oclib.PROCESSING_RESOURCE), id) o.ServeJSON() } // @Title Delete // @Description delete the processing // @Param id path string true "The id you want to delete" // @Success 200 {processing} delete success! // @router /:id [delete] func (o *ProcessingController) Delete() { id := o.Ctx.Input.Param(":id") o.Data["json"] = oclib.DeleteOne(oclib.LibDataEnum(oclib.PROCESSING_RESOURCE), id) o.ServeJSON() }