test *
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"cloud.o-forge.io/core/oc-lib/dbs/mongo"
|
||||
"cloud.o-forge.io/core/oc-lib/logs"
|
||||
"github.com/go-playground/validator/v10"
|
||||
@@ -15,6 +17,25 @@ type AbstractObject struct {
|
||||
Name string `json:"name" required:"true" bson:"name" validate:"required"`
|
||||
}
|
||||
|
||||
func (dma *AbstractObject) ObjDeserialize(j map[string]interface{}) *AbstractObject {
|
||||
b, err := json.Marshal(j)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
json.Unmarshal(b, dma)
|
||||
return dma
|
||||
}
|
||||
|
||||
func (dma *AbstractObject) ObjSerialize() map[string]interface{} {
|
||||
var m map[string]interface{}
|
||||
b, err := json.Marshal(dma)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
json.Unmarshal(b, dma)
|
||||
return m
|
||||
}
|
||||
|
||||
func (r *AbstractObject) GenerateID() {
|
||||
r.UUID = uuid.New().String()
|
||||
}
|
||||
|
Reference in New Issue
Block a user