init oc-workspace
This commit is contained in:
19
controllers/version.go
Normal file
19
controllers/version.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
// VersionController operations for Version
|
||||
type VersionController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
// @Title GetAll
|
||||
// @Description get version
|
||||
// @Success 200
|
||||
// @router / [get]
|
||||
func (c *VersionController) GetAll() {
|
||||
c.Data["json"] = map[string]string{"version": "1"}
|
||||
c.ServeJSON()
|
||||
}
|
||||
71
controllers/workspace.go
Normal file
71
controllers/workspace.go
Normal file
@@ -0,0 +1,71 @@
|
||||
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 WorkspaceController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
// @Title Update
|
||||
// @Description create workspaces
|
||||
// @Param id path string true "the workspace id you want to get"
|
||||
// @Param body body models.workspace true "The workspace content"
|
||||
// @Success 200 {workspace} models.workspace
|
||||
// @router /:id [put]
|
||||
func (o *WorkspaceController) 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.WORKSPACE), res, id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Create
|
||||
// @Description create workspace
|
||||
// @Param data body json true "body for data content (Json format)"
|
||||
// @Success 200 {workspace} models.workspace
|
||||
// @router / [post]
|
||||
func (o *WorkspaceController) Post() {
|
||||
var res map[string]interface{}
|
||||
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
|
||||
o.Data["json"] = oclib.StoreOne(oclib.LibDataEnum(oclib.WORKSPACE), res)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title GetAll
|
||||
// @Description find workspace by id
|
||||
// @Success 200 {workspace} models.workspace
|
||||
// @router / [get]
|
||||
func (o *WorkspaceController) GetAll() {
|
||||
o.Data["json"] = oclib.LoadAll(oclib.LibDataEnum(oclib.WORKSPACE))
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Get
|
||||
// @Description find workflow by id
|
||||
// @Param id path string true "the id you want to get"
|
||||
// @Success 200 {workspace} models.workspace
|
||||
// @router /:id [get]
|
||||
func (o *WorkspaceController) Get() {
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
o.Data["json"] = oclib.LoadOne(oclib.LibDataEnum(oclib.WORKSPACE), id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
// @Title Delete
|
||||
// @Description delete the workspace
|
||||
// @Param id path string true "The id you want to delete"
|
||||
// @Success 200 {workspace} delete success!
|
||||
// @router /:id [delete]
|
||||
func (o *WorkspaceController) Delete() {
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
o.Data["json"] = oclib.DeleteOne(oclib.LibDataEnum(oclib.WORKSPACE), id)
|
||||
o.ServeJSON()
|
||||
}
|
||||
Reference in New Issue
Block a user