84 lines
2.7 KiB
Go
84 lines
2.7 KiB
Go
|
package controllers
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
|
||
|
oclib "cloud.o-forge.io/core/oc-lib"
|
||
|
beego "github.com/beego/beego/v2/server/web"
|
||
|
)
|
||
|
|
||
|
// Operations about workspace
|
||
|
type SharedWorkspaceController struct {
|
||
|
beego.Controller
|
||
|
}
|
||
|
|
||
|
// @Title Search
|
||
|
// @Description search shared workspace
|
||
|
// @Param search path string true "the word search you want to get"
|
||
|
// @Success 200 {shared workspace} models.shared_workspace
|
||
|
// @router /search/:search [get]
|
||
|
func (o *SharedWorkspaceController) 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.SHARED_WORKSPACE))
|
||
|
o.ServeJSON()
|
||
|
}
|
||
|
|
||
|
// @Title Update
|
||
|
// @Description create shared workspaces
|
||
|
// @Param id path string true "the shared workspace id you want to get"
|
||
|
// @Param body body models.workspace true "The shared workspace content"
|
||
|
// @Success 200 {shared workspace} models.shared_workspace
|
||
|
// @router /:id [put]
|
||
|
func (o *SharedWorkspaceController) 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.SHARED_WORKSPACE), res, id)
|
||
|
o.ServeJSON()
|
||
|
}
|
||
|
|
||
|
// @Title Create
|
||
|
// @Description create shared workspace
|
||
|
// @Param data body json true "body for data content (Json format)"
|
||
|
// @Success 200 {shared workspace} models.shared_workspace
|
||
|
// @router / [post]
|
||
|
func (o *SharedWorkspaceController) Post() {
|
||
|
var res map[string]interface{}
|
||
|
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
||
|
o.Data["json"] = oclib.StoreOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res)
|
||
|
o.ServeJSON()
|
||
|
}
|
||
|
|
||
|
// @Title GetAll
|
||
|
// @Description find shared workspace by id
|
||
|
// @Success 200 {shared_workspace} models.shared_workspace
|
||
|
// @router / [get]
|
||
|
func (o *SharedWorkspaceController) GetAll() {
|
||
|
o.Data["json"] = oclib.LoadAll(oclib.LibDataEnum(oclib.SHARED_WORKSPACE))
|
||
|
o.ServeJSON()
|
||
|
}
|
||
|
|
||
|
// @Title Get
|
||
|
// @Description find shared workspace by id
|
||
|
// @Param id path string true "the id you want to get"
|
||
|
// @Success 200 {shared workspace} models.shared_workspace
|
||
|
// @router /:id [get]
|
||
|
func (o *SharedWorkspaceController) Get() {
|
||
|
id := o.Ctx.Input.Param(":id")
|
||
|
o.Data["json"] = oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
|
||
|
o.ServeJSON()
|
||
|
}
|
||
|
|
||
|
// @Title Delete
|
||
|
// @Description delete the shared workspace
|
||
|
// @Param id path string true "The id you want to delete"
|
||
|
// @Success 200 {shared workspace} delete success!
|
||
|
// @router /:id [delete]
|
||
|
func (o *SharedWorkspaceController) Delete() {
|
||
|
id := o.Ctx.Input.Param(":id")
|
||
|
o.Data["json"] = oclib.DeleteOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
|
||
|
o.ServeJSON()
|
||
|
}
|