Gradually adding support for all features

This commit is contained in:
Pavel Shevaev 2022-12-08 17:09:44 +03:00
parent ec77833c37
commit 45d7b0bfac
1 changed files with 52 additions and 0 deletions

View File

@ -100,6 +100,10 @@ func (self *{{o.name}}) WriteFields(writer meta.Writer) error {
{{_self.stats_methods(meta, o)}}
{% endif %}
{% if has_token(o, 'POD') and has_token(o, 'id') and has_token(o, 'table') and has_token(o, 'owner') %}
{{_self.db_item_methods(meta, o)}}
{% endif %}
{% endmacro %}
{% macro props_map(tokens) %}
@ -260,6 +264,54 @@ func (self *{{o.name}}) Values() []interface{} {
{% endmacro %}
{% macro db_item_methods(meta, o) %}
func (self *{{o.name}}) NewInstance() meta.IMetaDataItem {
return New{{o.name}}()
}
func (self *{{o.name}}) GetDbTableName() string {
return "{{token(o, 'table')}}"
}
func (self *{{o.name}}) GetDbFields() []string {
return self.CLASS_FIELDS()
}
func (self *{{o.name}}) GetOwnerFieldName() string {
return "{{token(o, 'owner')}}"
}
func (self *{{o.name}}) GetIdFieldName() string {
return "{{token(o, 'id')}}"
}
func (self *{{o.name}}) GetIdValue() uint64 {
return uint64(self.{{token(o, 'id')|ucfirst}})
}
func (self *{{o.name}}) Import(data interface{}) {
switch data.(type) {
case {{o.name}}:
{
row := data.({{o.name}})
{%- for f in get_all_fields(meta, o) ~%}
self.{{f.name|ucfirst}} = row.{{f.name|ucfirst}}
{%- endfor ~%}
break
}
default:
break
}
}
func (self *{{o.name}}) Export(data []interface{}) {
{%- for f in get_all_fields(meta, o) ~%}
data[{{loop.index0}}] = self.{{f.name|ucfirst}}
{%- endfor ~%}
}
{% endmacro %}
{% macro decl_enum(o) %}
//==============================