Skip to content
Snippets Groups Projects
Commit 32dc837e authored by Danis Kirasirov's avatar Danis Kirasirov
Browse files

Использование тега expr вместо интерфейса Mapper

parent 748cd707
No related branches found
No related tags found
No related merge requests found
......@@ -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
......@@ -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 {
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment