Adding Workspace Logic

This commit is contained in:
mr
2024-07-25 09:28:55 +02:00
parent 51e94e73e5
commit 094ae0a7f0
8 changed files with 203 additions and 7 deletions

View File

@@ -0,0 +1,51 @@
package workspace
import (
"encoding/json"
"cloud.o-forge.io/core/oc-lib/models/utils"
"github.com/google/uuid"
)
type Workspace struct {
utils.AbstractObject
utils.ResourceSet
Active bool `json:"active" bson:"active" default:"false"`
}
func (ao *Workspace) GetID() string {
return ao.UUID
}
func (r *Workspace) GenerateID() {
r.UUID = uuid.New().String()
}
func (d *Workspace) GetName() string {
return d.Name
}
func (d *Workspace) GetAccessor() utils.Accessor {
data := &WorkspaceMongoAccessor{}
data.SetLogger(utils.WORKFLOW)
return data
}
func (dma *Workspace) Deserialize(j map[string]interface{}) utils.DBObject {
b, err := json.Marshal(j)
if err != nil {
return nil
}
json.Unmarshal(b, dma)
return dma
}
func (dma *Workspace) Serialize() map[string]interface{} {
var m map[string]interface{}
b, err := json.Marshal(dma)
if err != nil {
return nil
}
json.Unmarshal(b, &m)
return m
}