Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
perxis-go
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package Registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
perxis
perxis-go
Commits
32dc837e
Commit
32dc837e
authored
1 year ago
by
Danis Kirasirov
Browse files
Options
Downloads
Patches
Plain Diff
Использование тега expr вместо интерфейса Mapper
parent
748cd707
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pkg/expr/expr.go
+0
-9
0 additions, 9 deletions
pkg/expr/expr.go
pkg/files/file.go
+6
-17
6 additions, 17 deletions
pkg/files/file.go
pkg/references/reference.go
+3
-10
3 additions, 10 deletions
pkg/references/reference.go
with
9 additions
and
36 deletions
pkg/expr/expr.go
+
0
−
9
View file @
32dc837e
...
...
@@ -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
This diff is collapsed.
Click to expand it.
pkg/files/file.go
+
6
−
17
View file @
32dc837e
...
...
@@ -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
{
...
...
This diff is collapsed.
Click to expand it.
pkg/references/reference.go
+
3
−
10
View file @
32dc837e
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment