Skip to content
Snippets Groups Projects
Commit 2defe6a5a126 authored by Christophe de Vienne's avatar Christophe de Vienne
Browse files

Generate url builders

parent 5746457e68bc
No related branches found
No related tags found
No related merge requests found
Pipeline #26811 passed
......@@ -275,6 +275,7 @@
PKeyColumn() string
Columns(withPKey bool) []string
Values(columns ...string) []interface{}
ValuesMap(columns ...string) map[string]interface{}
}
type TableSchema interface {
......@@ -483,6 +484,20 @@
return values
}
// ValuesMap returns the values map for a list of columns. If a column does not
// exits, the corresponding value is left empty
func (s {{.Name}}) ValuesMap(columns ...string) map[string]interface{} {
values := make(map[string]interface{})
for _, column := range columns {
switch column {
{{- range .Fields}}
case "{{.Column}}":
values["{{.Column}}"] = s.{{.Name}}
{{- end}}
}
}
return values
}
{{- if .HasTable}}
func New{{.Name}}TableSchema() *{{.Name}}TableSchema {
......
......@@ -95,6 +95,11 @@
source: asset:serverOperation
target: "{{ if gt (len .Tags) 0 }}{{ joinFilePath .Target .ServerPackage .APIPackage .Package }}{{ else }}{{ joinFilePath .Target .ServerPackage .Package }}{{ end }}"
file_name: "{{ (snakize (pascalize .Name)) }}.go"
- name: urlbuilder
source: "asset:serverUrlbuilder"
target: "{{ if .UseTags }}{{ joinFilePath .Target (toPackagePath .ServerPackage) (toPackagePath .APIPackage) (toPackagePath .Package) }}{{ else }}{{ joinFilePath .Target (toPackagePath .ServerPackage) (toPackagePath .Package) }}{{ end }}"
file_name: "{{ (snakize (pascalize .Name)) }}_urlbuilder.go"
# custom templates
- name: prometheus
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment