new oc-shared

This commit is contained in:
mr
2024-09-27 14:08:14 +02:00
parent 18fe4b01ed
commit 3b50954ae4
8 changed files with 259 additions and 247 deletions

View File

@@ -12,7 +12,7 @@ import (
)
// Operations about workspace
type SharedWorkspaceController struct {
type CollaborativeAreaController struct {
beego.Controller
}
@@ -21,10 +21,10 @@ type SharedWorkspaceController struct {
// @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() {
func (o *CollaborativeAreaController) 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.Data["json"] = oclib.Search(nil, search, oclib.LibDataEnum(utils.COLLABORATIVE_AREA))
o.ServeJSON()
}
@@ -34,12 +34,12 @@ func (o *SharedWorkspaceController) Search() {
// @Param body body models.workspace true "The shared workspace content"
// @Success 200 {shared workspace} models.shared_workspace
// @router /:id [put]
func (o *SharedWorkspaceController) Put() {
func (o *CollaborativeAreaController) Put() {
// store and return Id or post with UUID
var paths = map[string]map[tools.METHOD]string{ // paths used to send to peers
utils.SHARED_WORKSPACE.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
utils.COLLABORATIVE_AREA.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(utils.COLLABORATIVE_AREA)) + "/oc/shared/workspace/:id",
tools.POST: oclib.GetPath(oclib.LibDataEnum(utils.COLLABORATIVE_AREA)) + "/oc/shared/workspace/",
},
utils.WORKSPACE.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
@@ -58,7 +58,7 @@ func (o *SharedWorkspaceController) Put() {
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
fmt.Println("UPDATE", res)
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), res, id, caller)
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(utils.COLLABORATIVE_AREA), res, id, caller)
o.ServeJSON()
}
@@ -67,11 +67,11 @@ func (o *SharedWorkspaceController) Put() {
// @Param data body json true "body for data content (Json format)"
// @Success 200 {shared workspace} models.shared_workspace
// @router / [post]
func (o *SharedWorkspaceController) Post() {
func (o *CollaborativeAreaController) Post() {
var paths = map[string]map[tools.METHOD]string{ // paths used to call other OC services
utils.SHARED_WORKSPACE.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
utils.COLLABORATIVE_AREA.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(utils.COLLABORATIVE_AREA)) + "/oc/shared/workspace/:id",
tools.POST: oclib.GetPath(oclib.LibDataEnum(utils.COLLABORATIVE_AREA)) + "/oc/shared/workspace/",
},
utils.WORKSPACE.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
@@ -89,7 +89,7 @@ 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, caller)
o.Data["json"] = oclib.StoreOne(oclib.LibDataEnum(utils.COLLABORATIVE_AREA), res, caller)
o.ServeJSON()
}
@@ -97,8 +97,8 @@ func (o *SharedWorkspaceController) Post() {
// @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))
func (o *CollaborativeAreaController) GetAll() {
o.Data["json"] = oclib.LoadAll(oclib.LibDataEnum(utils.COLLABORATIVE_AREA))
o.ServeJSON()
}
@@ -107,9 +107,9 @@ func (o *SharedWorkspaceController) GetAll() {
// @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() {
func (o *CollaborativeAreaController) Get() {
id := o.Ctx.Input.Param(":id")
o.Data["json"] = oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
o.Data["json"] = oclib.LoadOne(oclib.LibDataEnum(utils.COLLABORATIVE_AREA), id)
o.ServeJSON()
}
@@ -119,11 +119,11 @@ func (o *SharedWorkspaceController) Get() {
// @Param id2 path string true "the id you want to add"
// @Success 200 {shared workspace} models.shared_workspace
// @router /:id/workspace/:id2 [delete]
func (o *SharedWorkspaceController) RemoveWorkspace() {
func (o *CollaborativeAreaController) RemoveWorkspace() {
var paths = map[string]map[tools.METHOD]string{ // paths used to call other OC services
utils.SHARED_WORKSPACE.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
utils.COLLABORATIVE_AREA.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(utils.COLLABORATIVE_AREA)) + "/oc/shared/workspace/:id",
tools.POST: oclib.GetPath(oclib.LibDataEnum(utils.COLLABORATIVE_AREA)) + "/oc/shared/workspace/",
},
utils.WORKSPACE.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
@@ -140,8 +140,8 @@ func (o *SharedWorkspaceController) RemoveWorkspace() {
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
id := o.Ctx.Input.Param(":id")
id2 := o.Ctx.Input.Param(":id2")
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
shared := r.ToSharedWorkspace()
r := oclib.LoadOne(oclib.LibDataEnum(utils.COLLABORATIVE_AREA), id)
shared := r.ToCollaborativeArea()
newWorkspace := []string{}
if slices.Contains(shared.Workspaces, id2) {
for _, w := range shared.Workspaces {
@@ -151,7 +151,7 @@ func (o *SharedWorkspaceController) RemoveWorkspace() {
}
shared.Workspaces = newWorkspace
}
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), shared.Serialize(), id, caller)
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(utils.COLLABORATIVE_AREA), shared.Serialize(), id, caller)
o.ServeJSON()
}
@@ -161,11 +161,11 @@ func (o *SharedWorkspaceController) RemoveWorkspace() {
// @Param id2 path string true "the id you want to add"
// @Success 200 {shared workspace} models.shared_workspace
// @router /:id/workflow/:id2 [delete]
func (o *SharedWorkspaceController) RemoveWorkflow() {
func (o *CollaborativeAreaController) RemoveWorkflow() {
var paths = map[string]map[tools.METHOD]string{ // paths used to call other OC services
utils.SHARED_WORKSPACE.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
utils.COLLABORATIVE_AREA.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(utils.COLLABORATIVE_AREA)) + "/oc/shared/workspace/:id",
tools.POST: oclib.GetPath(oclib.LibDataEnum(utils.COLLABORATIVE_AREA)) + "/oc/shared/workspace/",
},
utils.WORKSPACE.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
@@ -182,9 +182,9 @@ func (o *SharedWorkspaceController) RemoveWorkflow() {
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
id := o.Ctx.Input.Param(":id")
id2 := o.Ctx.Input.Param(":id2")
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
r := oclib.LoadOne(oclib.LibDataEnum(utils.COLLABORATIVE_AREA), id)
fmt.Println("RemoveWorkflow", r)
shared := r.ToSharedWorkspace()
shared := r.ToCollaborativeArea()
newWorkflows := []string{}
if slices.Contains(shared.Workflows, id2) {
for _, w := range shared.Workflows {
@@ -194,7 +194,7 @@ func (o *SharedWorkspaceController) RemoveWorkflow() {
}
shared.Workflows = newWorkflows
}
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), shared.Serialize(), id, caller)
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(utils.COLLABORATIVE_AREA), shared.Serialize(), id, caller)
o.ServeJSON()
}
@@ -204,11 +204,11 @@ func (o *SharedWorkspaceController) RemoveWorkflow() {
// @Param id2 path string true "the id you want to add"
// @Success 200 {shared workspace} models.shared_workspace
// @router /:id/peer/:id2 [delete]
func (o *SharedWorkspaceController) RemovePeer() {
func (o *CollaborativeAreaController) RemovePeer() {
var paths = map[string]map[tools.METHOD]string{ // paths used to call other OC services
utils.SHARED_WORKSPACE.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
utils.COLLABORATIVE_AREA.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(utils.COLLABORATIVE_AREA)) + "/oc/shared/workspace/:id",
tools.POST: oclib.GetPath(oclib.LibDataEnum(utils.COLLABORATIVE_AREA)) + "/oc/shared/workspace/",
},
utils.WORKSPACE.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
@@ -225,8 +225,8 @@ func (o *SharedWorkspaceController) RemovePeer() {
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
id := o.Ctx.Input.Param(":id")
id2 := o.Ctx.Input.Param(":id2")
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
shared := r.ToSharedWorkspace()
r := oclib.LoadOne(oclib.LibDataEnum(utils.COLLABORATIVE_AREA), id)
shared := r.ToCollaborativeArea()
newPeers := []string{}
if shared.CreatorID != id2 {
o.Data["json"] = map[string]interface{}{
@@ -245,7 +245,7 @@ func (o *SharedWorkspaceController) RemovePeer() {
}
shared.Peers = newPeers
}
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), shared.Serialize(), id, caller)
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(utils.COLLABORATIVE_AREA), shared.Serialize(), id, caller)
o.ServeJSON()
}
@@ -255,11 +255,11 @@ func (o *SharedWorkspaceController) RemovePeer() {
// @Param id2 path string true "the id you want to add"
// @Success 200 {shared workspace} models.shared_workspace
// @router /:id/rule/:id2 [delete]
func (o *SharedWorkspaceController) RemoveRule() {
func (o *CollaborativeAreaController) RemoveRule() {
var paths = map[string]map[tools.METHOD]string{ // paths used to call other OC services
utils.SHARED_WORKSPACE.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
utils.COLLABORATIVE_AREA.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(utils.COLLABORATIVE_AREA)) + "/oc/shared/workspace/:id",
tools.POST: oclib.GetPath(oclib.LibDataEnum(utils.COLLABORATIVE_AREA)) + "/oc/shared/workspace/",
},
utils.WORKSPACE.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
@@ -276,8 +276,8 @@ func (o *SharedWorkspaceController) RemoveRule() {
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
id := o.Ctx.Input.Param(":id")
id2 := o.Ctx.Input.Param(":id2")
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
shared := r.ToSharedWorkspace()
r := oclib.LoadOne(oclib.LibDataEnum(utils.COLLABORATIVE_AREA), id)
shared := r.ToCollaborativeArea()
newRules := []string{}
if shared != nil && slices.Contains(shared.Rules, id2) {
for _, rule := range shared.Rules {
@@ -287,7 +287,7 @@ func (o *SharedWorkspaceController) RemoveRule() {
}
shared.Rules = newRules
}
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), shared.Serialize(), id, caller)
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(utils.COLLABORATIVE_AREA), shared.Serialize(), id, caller)
o.ServeJSON()
}
@@ -297,11 +297,11 @@ func (o *SharedWorkspaceController) RemoveRule() {
// @Param id2 path string true "the id you want to add"
// @Success 200 {shared workspace} models.shared_workspace
// @router /:id/workspace/:id2 [post]
func (o *SharedWorkspaceController) AddWorkspace() {
func (o *CollaborativeAreaController) AddWorkspace() {
var paths = map[string]map[tools.METHOD]string{ // paths used to call other OC services
utils.SHARED_WORKSPACE.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
utils.COLLABORATIVE_AREA.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(utils.COLLABORATIVE_AREA)) + "/oc/shared/workspace/:id",
tools.POST: oclib.GetPath(oclib.LibDataEnum(utils.COLLABORATIVE_AREA)) + "/oc/shared/workspace/",
},
utils.WORKSPACE.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
@@ -318,17 +318,17 @@ func (o *SharedWorkspaceController) AddWorkspace() {
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
id := o.Ctx.Input.Param(":id")
id2 := o.Ctx.Input.Param(":id2")
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
r := oclib.LoadOne(oclib.LibDataEnum(utils.COLLABORATIVE_AREA), id)
if r.Code != 200 {
o.Data["json"] = r
o.ServeJSON()
return
}
shared := r.ToSharedWorkspace()
shared := r.ToCollaborativeArea()
if shared != nil && !slices.Contains(shared.Workspaces, id2) {
shared.Workspaces = append(shared.Workspaces, id2)
}
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), shared.Serialize(), id, caller)
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(utils.COLLABORATIVE_AREA), shared.Serialize(), id, caller)
o.ServeJSON()
}
@@ -338,11 +338,11 @@ func (o *SharedWorkspaceController) AddWorkspace() {
// @Param id2 path string true "the id you want to add"
// @Success 200 {shared workspace} models.shared_workspace
// @router /:id/workflow/:id2 [post]
func (o *SharedWorkspaceController) AddWorkflow() {
func (o *CollaborativeAreaController) AddWorkflow() {
var paths = map[string]map[tools.METHOD]string{ // paths used to call other OC services
utils.SHARED_WORKSPACE.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
utils.COLLABORATIVE_AREA.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(utils.COLLABORATIVE_AREA)) + "/oc/shared/workspace/:id",
tools.POST: oclib.GetPath(oclib.LibDataEnum(utils.COLLABORATIVE_AREA)) + "/oc/shared/workspace/",
},
utils.WORKSPACE.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
@@ -360,14 +360,14 @@ func (o *SharedWorkspaceController) AddWorkflow() {
id := o.Ctx.Input.Param(":id")
id2 := o.Ctx.Input.Param(":id2")
fmt.Println("AddWorkflow", id, id2)
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
shared := r.ToSharedWorkspace()
r := oclib.LoadOne(oclib.LibDataEnum(utils.COLLABORATIVE_AREA), id)
shared := r.ToCollaborativeArea()
if shared != nil && !slices.Contains(shared.Workflows, id2) {
shared.Workflows = append(shared.Workflows, id2)
}
fmt.Println("AddWorkflow", shared.Workflows)
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), shared.Serialize(), id, caller)
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(utils.COLLABORATIVE_AREA), shared.Serialize(), id, caller)
o.ServeJSON()
}
@@ -377,11 +377,11 @@ func (o *SharedWorkspaceController) AddWorkflow() {
// @Param id2 path string true "the id you want to add"
// @Success 200 {shared workspace} models.shared_workspace
// @router /:id/peer/:id2 [post]
func (o *SharedWorkspaceController) AddPeer() {
func (o *CollaborativeAreaController) AddPeer() {
var paths = map[string]map[tools.METHOD]string{ // paths used to call other OC services
utils.SHARED_WORKSPACE.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
utils.COLLABORATIVE_AREA.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(utils.COLLABORATIVE_AREA)) + "/oc/shared/workspace/:id",
tools.POST: oclib.GetPath(oclib.LibDataEnum(utils.COLLABORATIVE_AREA)) + "/oc/shared/workspace/",
},
utils.WORKSPACE.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
@@ -398,12 +398,12 @@ func (o *SharedWorkspaceController) AddPeer() {
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
id := o.Ctx.Input.Param(":id")
id2 := o.Ctx.Input.Param(":id2")
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
shared := r.ToSharedWorkspace()
r := oclib.LoadOne(oclib.LibDataEnum(utils.COLLABORATIVE_AREA), id)
shared := r.ToCollaborativeArea()
if shared != nil && !slices.Contains(shared.Peers, id2) {
shared.Peers = append(shared.Peers, id2)
}
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), shared.Serialize(), id, caller)
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(utils.COLLABORATIVE_AREA), shared.Serialize(), id, caller)
o.ServeJSON()
}
@@ -413,11 +413,11 @@ func (o *SharedWorkspaceController) AddPeer() {
// @Param id2 path string true "the id you want to add"
// @Success 200 {shared workspace} models.shared_workspace
// @router /:id/rule/:id2 [post]
func (o *SharedWorkspaceController) AddRule() {
func (o *CollaborativeAreaController) AddRule() {
var paths = map[string]map[tools.METHOD]string{ // paths used to send to peers
utils.SHARED_WORKSPACE.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
utils.COLLABORATIVE_AREA.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(utils.COLLABORATIVE_AREA)) + "/oc/shared/workspace/:id",
tools.POST: oclib.GetPath(oclib.LibDataEnum(utils.COLLABORATIVE_AREA)) + "/oc/shared/workspace/",
},
utils.WORKSPACE.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
@@ -434,12 +434,12 @@ func (o *SharedWorkspaceController) AddRule() {
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
id := o.Ctx.Input.Param(":id")
id2 := o.Ctx.Input.Param(":id2")
r := oclib.LoadOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id)
shared := r.ToSharedWorkspace()
r := oclib.LoadOne(oclib.LibDataEnum(utils.COLLABORATIVE_AREA), id)
shared := r.ToCollaborativeArea()
if shared != nil && !slices.Contains(shared.Rules, id2) {
shared.Rules = append(shared.Rules, id2)
}
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), shared.Serialize(), id, caller)
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(utils.COLLABORATIVE_AREA), shared.Serialize(), id, caller)
o.ServeJSON()
}
@@ -448,11 +448,11 @@ func (o *SharedWorkspaceController) AddRule() {
// @Param id path string true "The id you want to delete"
// @Success 200 {shared workspace} delete success!
// @router /:id [delete]
func (o *SharedWorkspaceController) Delete() {
func (o *CollaborativeAreaController) Delete() {
var paths = map[string]map[tools.METHOD]string{ // paths used to send to peers
utils.SHARED_WORKSPACE.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
utils.COLLABORATIVE_AREA.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(utils.COLLABORATIVE_AREA)) + "/oc/shared/workspace/:id",
tools.POST: oclib.GetPath(oclib.LibDataEnum(utils.COLLABORATIVE_AREA)) + "/oc/shared/workspace/",
},
utils.WORKSPACE.String(): {
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
@@ -468,6 +468,6 @@ func (o *SharedWorkspaceController) Delete() {
}
id := o.Ctx.Input.Param(":id")
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
o.Data["json"] = oclib.DeleteOne(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), id, caller)
o.Data["json"] = oclib.DeleteOne(oclib.LibDataEnum(utils.COLLABORATIVE_AREA), id, caller)
o.ServeJSON()
}