3
0

Add Name & Type to types.Field

This commit is contained in:
Denis Arh 2018-07-17 11:03:34 +02:00
parent 601f512667
commit 3bbb094e84
3 changed files with 42 additions and 3 deletions

View File

@ -9,7 +9,10 @@
"struct": [
{
"name": "Field",
"fields": []
"fields": [
{ "name": "Name", "type": "string", "tag": "json:\"name\"" },
{ "name": "Type", "type": "string", "tag": "json:\"type\"" }
]
}
],
"apis": [
@ -114,4 +117,4 @@
}
]
}
]
]

View File

@ -5,7 +5,18 @@
"Interface": "Field",
"Struct": [
{
"fields": [],
"fields": [
{
"name": "Name",
"tag": "json:\"name\"",
"type": "string"
},
{
"name": "Type",
"tag": "json:\"type\"",
"type": "string"
}
],
"name": "Field"
}
],

View File

@ -18,6 +18,9 @@ package types
type (
// Fields
Field struct {
Name string `json:"name" db:"name"`
Type string `json:"type" db:"type"`
changed []string
}
)
@ -28,3 +31,25 @@ func (Field) New() *Field {
}
/* Getters/setters */
func (f *Field) GetName() string {
return f.Name
}
func (f *Field) SetName(value string) *Field {
if f.Name != value {
f.changed = append(f.changed, "Name")
f.Name = value
}
return f
}
func (f *Field) GetType() string {
return f.Type
}
func (f *Field) SetType(value string) *Field {
if f.Type != value {
f.changed = append(f.changed, "Type")
f.Type = value
}
return f
}