mirror of
https://github.com/hay-kot/homebox.git
synced 2024-12-24 15:56:31 +00:00
23 lines
772 B
Go
23 lines
772 B
Go
|
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 }}
|
||
|
}
|
||
|
}
|
||
|
`
|