diff --git a/pkg/expr/expr.go b/pkg/expr/expr.go index 3f346889f52af08e87a431caecf1513768fc12c1..1969b58c6bec892b05f8eff38eec86f3d4099e01 100644 --- a/pkg/expr/expr.go +++ b/pkg/expr/expr.go @@ -31,11 +31,6 @@ func Eval(ctx context.Context, input string, env map[string]interface{}) (interf } for k, v := range env { - if mapper, ok := v.(Mapper); ok { - e[k] = mapper.ToMap() - continue - } - e[k] = v } @@ -83,8 +78,4 @@ func IsExpression(input string) bool { } return false -} - -type Mapper interface { - ToMap() map[string]interface{} } \ No newline at end of file diff --git a/pkg/files/file.go b/pkg/files/file.go index fc12151b69655ecef0a8f6309c54e02e65fc76f0..5700309d4e180d8a242eccc87bf8ed4581ff39bd 100644 --- a/pkg/files/file.go +++ b/pkg/files/file.go @@ -16,12 +16,12 @@ const ( // File - описание файла РІ системе хранения perxis type File struct { - ID string `mapstructure:"id,omitempty" json:"id"` // Уникальный идентификатор файла РІ хранилище - Name string `mapstructure:"name,omitempty" json:"name" bson:"name,omitempty"` // РРјСЏ файла - Size int `mapstructure:"size,omitempty" json:"size" bson:"size,omitempty"` // Размер файла - MimeType string `mapstructure:"mimeType,omitempty" json:"mimeType" bson:"mimeType,omitempty"` // Mime-type файла - URL string `mapstructure:"url,omitempty" json:"url" bson:"url,omitempty"` // Адрес для загрузки файла - Key string `mapstructure:"key,omitempty" json:"key" bson:"key,omitempty"` // Ключ для хранения файла РІ хранилище + ID string `mapstructure:"id,omitempty" json:"id" expr:"id"` // Уникальный идентификатор файла РІ хранилище + Name string `mapstructure:"name,omitempty" json:"name" bson:"name,omitempty" expr:"name"` // РРјСЏ файла + Size int `mapstructure:"size,omitempty" json:"size" bson:"size,omitempty" expr:"size"` // Размер файла + MimeType string `mapstructure:"mimeType,omitempty" json:"mimeType" bson:"mimeType,omitempty" expr:"mime_type"` // Mime-type файла + URL string `mapstructure:"url,omitempty" json:"url" bson:"url,omitempty" expr:"url"` // Адрес для загрузки файла + Key string `mapstructure:"key,omitempty" json:"key" bson:"key,omitempty" expr:"key"` // Ключ для хранения файла РІ хранилище File fs.File `mapstructure:"-" json:"-" bson:"-"` // Файл для загрузки(РёР· файловой системы) } @@ -47,17 +47,6 @@ func (f *File) SetURLWithTemplate(t *template.Template) error { return nil } -func (f File) ToMap() map[string]interface{} { - return map[string]interface{}{ - "id": f.ID, - "name": f.Name, - "size": f.Size, - "mime_type": f.MimeType, - "url": f.URL, - "key": f.Key, - } -} - func NewFile(name, mimeType string, size int, temp bool) *File { i := id.GenerateNewID() if temp { diff --git a/pkg/references/reference.go b/pkg/references/reference.go index b1b56953f98131dfebf69c41c3ff53299ff09384..171ded420c3fd5601cac9ad9f74ad69883f964ea 100644 --- a/pkg/references/reference.go +++ b/pkg/references/reference.go @@ -7,9 +7,9 @@ import ( ) type Reference struct { - ID string `json:"id" bson:"id" mapstructure:"id"` - CollectionID string `json:"collection_id" bson:"collection_id" mapstructure:"collection_id"` - Disabled bool `json:"disabled,omitempty" bson:"disabled,omitempty" mapstructure:"disabled"` + ID string `json:"id" bson:"id" mapstructure:"id" expr:"id"` + CollectionID string `json:"collection_id" bson:"collection_id" mapstructure:"collection_id" expr:"collection_id"` + Disabled bool `json:"disabled,omitempty" bson:"disabled,omitempty" mapstructure:"disabled" expr:"disabled"` } func (r *Reference) MarshalBSON() ([]byte, error) { @@ -25,13 +25,6 @@ func (r *Reference) MarshalBSON() ([]byte, error) { return bson.Marshal(d) } -func (r *Reference) ToMap() map[string]interface{} { - return map[string]interface{}{ - "collection_id": r.CollectionID, - "id": r.ID, - } -} - func ReferenceFromPB(refPB *pb.Reference) *Reference { if refPB == nil { return nil