A question refers to the comment ! And if not Ooopsy
This commit is contained in:
@@ -8,20 +8,27 @@ import (
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
/*
|
||||
* AbstractResource is a struct that represents a resource
|
||||
* it defines the resource data
|
||||
*/
|
||||
type AbstractResource struct {
|
||||
utils.AbstractObject
|
||||
ShortDescription string `json:"short_description,omitempty" bson:"short_description,omitempty" validate:"required"`
|
||||
Description string `json:"description,omitempty" bson:"description,omitempty"`
|
||||
Logo string `json:"logo,omitempty" bson:"logo,omitempty" validate:"required"`
|
||||
Owner string `json:"owner,omitempty" bson:"owner,omitempty" validate:"required"`
|
||||
OwnerLogo string `json:"owner_logo,omitempty" bson:"owner_logo,omitempty"`
|
||||
SourceUrl string `json:"source_url,omitempty" bson:"source_url,omitempty" validate:"required"`
|
||||
PeerID string `json:"peer_id,omitempty" bson:"peer_id,omitempty" validate:"required"`
|
||||
Price string `json:"price,omitempty" bson:"price,omitempty"`
|
||||
License string `json:"license,omitempty" bson:"license,omitempty"`
|
||||
ResourceModel *ResourceModel `json:"resource_model,omitempty" bson:"resource_model,omitempty"`
|
||||
utils.AbstractObject // AbstractObject contains the basic fields of an object (id, name)
|
||||
ShortDescription string `json:"short_description,omitempty" bson:"short_description,omitempty" validate:"required"` // ShortDescription is the short description of the resource
|
||||
Description string `json:"description,omitempty" bson:"description,omitempty"` // Description is the description of the resource
|
||||
Logo string `json:"logo,omitempty" bson:"logo,omitempty" validate:"required"` // Logo is the logo of the resource
|
||||
Owner string `json:"owner,omitempty" bson:"owner,omitempty" validate:"required"` // Owner is the owner of the resource
|
||||
OwnerLogo string `json:"owner_logo,omitempty" bson:"owner_logo,omitempty"` // OwnerLogo is the owner logo of the resource
|
||||
SourceUrl string `json:"source_url,omitempty" bson:"source_url,omitempty" validate:"required"` // SourceUrl is the source URL of the resource
|
||||
PeerID string `json:"peer_id,omitempty" bson:"peer_id,omitempty" validate:"required"` // PeerID is the ID of the peer getting this resource
|
||||
Price string `json:"price,omitempty" bson:"price,omitempty"` // Price is the price of access to the resource
|
||||
License string `json:"license,omitempty" bson:"license,omitempty"` // License is the license of the resource
|
||||
ResourceModel *ResourceModel `json:"resource_model,omitempty" bson:"resource_model,omitempty"` // ResourceModel is the model of the resource
|
||||
}
|
||||
|
||||
/*
|
||||
* GetModelValue returns the value of the model key
|
||||
*/
|
||||
func (abs *AbstractResource) GetModelValue(key string) interface{} {
|
||||
if abs.ResourceModel == nil || abs.ResourceModel.Model == nil {
|
||||
return nil
|
||||
@@ -32,6 +39,9 @@ func (abs *AbstractResource) GetModelValue(key string) interface{} {
|
||||
return abs.ResourceModel.Model[key].Value
|
||||
}
|
||||
|
||||
/*
|
||||
* GetModelType returns the type of the model key
|
||||
*/
|
||||
func (abs *AbstractResource) GetModelType(key string) interface{} {
|
||||
if abs.ResourceModel == nil || abs.ResourceModel.Model == nil {
|
||||
return nil
|
||||
@@ -42,6 +52,9 @@ func (abs *AbstractResource) GetModelType(key string) interface{} {
|
||||
return abs.ResourceModel.Model[key].Type
|
||||
}
|
||||
|
||||
/*
|
||||
* GetModelKeys returns the keys of the model
|
||||
*/
|
||||
func (abs *AbstractResource) GetModelKeys() []string {
|
||||
keys := make([]string, 0)
|
||||
for k := range abs.ResourceModel.Model {
|
||||
@@ -50,6 +63,9 @@ func (abs *AbstractResource) GetModelKeys() []string {
|
||||
return keys
|
||||
}
|
||||
|
||||
/*
|
||||
* GetModelReadOnly returns the readonly of the model key
|
||||
*/
|
||||
func (abs *AbstractResource) GetModelReadOnly(key string) interface{} {
|
||||
if abs.ResourceModel == nil || abs.ResourceModel.Model == nil {
|
||||
return nil
|
||||
@@ -61,11 +77,16 @@ func (abs *AbstractResource) GetModelReadOnly(key string) interface{} {
|
||||
}
|
||||
|
||||
type Model struct {
|
||||
Type string `json:"type,omitempty" bson:"type,omitempty"`
|
||||
Value interface{} `json:"value,omitempty" bson:"value,omitempty"`
|
||||
ReadOnly bool `json:"readonly,omitempty" bson:"readonly,omitempty"`
|
||||
Type string `json:"type,omitempty" bson:"type,omitempty"` // Type is the type of the model
|
||||
Value interface{} `json:"value,omitempty" bson:"value,omitempty"` // Value is the value of the model
|
||||
ReadOnly bool `json:"readonly,omitempty" bson:"readonly,omitempty"` // ReadOnly is the readonly of the model
|
||||
}
|
||||
|
||||
/*
|
||||
* ResourceModel is a struct that represents a resource model
|
||||
* it defines the resource metadata and specificity
|
||||
* Warning: This struct is not user available, it is only used by the system
|
||||
*/
|
||||
type ResourceModel struct {
|
||||
UUID string `json:"id,omitempty" bson:"id,omitempty" validate:"required"`
|
||||
ResourceType string `json:"resource_type,omitempty" bson:"resource_type,omitempty" validate:"required"`
|
||||
|
@@ -7,9 +7,13 @@ import (
|
||||
)
|
||||
|
||||
type ResourceModelMongoAccessor struct {
|
||||
utils.AbstractAccessor
|
||||
utils.AbstractAccessor // AbstractAccessor contains the basic fields of an accessor (model, caller)
|
||||
}
|
||||
|
||||
/*
|
||||
* Nothing special here, just the basic CRUD operations
|
||||
*/
|
||||
|
||||
func (wfa *ResourceModelMongoAccessor) DeleteOne(id string) (utils.DBObject, int, error) {
|
||||
return wfa.GenericDeleteOne(id, wfa)
|
||||
}
|
||||
|
Reference in New Issue
Block a user