homebox/backend/pkgs/automapper/templates.go

23 lines
772 B
Go
Raw Normal View History

2022-08-30 02:30:36 +00:00
package automapper
var automapperTemplate = `// Code generated by "/pkgs/automapper"; DO NOT EDIT.
package {{ .Package }}
import (
{{ range $import := .Imports }}"{{ $import }}"
{{ end }}
)
func {{ .Schema.Reference }}FromModel(from {{ .Model.Prefix}}.{{ .Model.Reference }}) {{ .Schema.Prefix}}.{{ .Schema.Reference }} {
return {{ .Schema.Prefix}}.{{ .Schema.Reference }}{ {{ range $i, $f := .FieldAssignments }}
{{ $f.SchemaField }}: from.{{ $f.ModelField }},{{ end }}
}
}
func {{ .Schema.Reference }}ToModel(from {{ .Schema.Prefix}}.{{ .Schema.Reference }}) {{ .Model.Prefix}}.{{ .Model.Reference }} {
return {{ .Model.Prefix}}.{{ .Model.Reference }}{ {{ range $i, $f := .FieldAssignments }}
{{ $f.ModelField }}: from.{{ $f.SchemaField }},{{ end }}
}
}
`