Skip to content

Commit 098a96f

Browse files
committed
Update model template
1 parent 5ec501b commit 098a96f

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

gen/templates/feature_templates/model.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context) string {
171171
body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "constant")
172172
body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue", data.{{toGoName .TfName}}.Value{{.Type}}())
173173
{{- if and (.RequiresConstAndVar) (.Variable) }}
174-
body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipVariableName", data.{{toGoName .TfName}}Variable.ValueString())
174+
body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipVariableName", data.{{toGoName .TfName}}Variable.Value{{.Type}}())
175175
{{end}}
176176
}
177177
{{- else if and (eq .Type "Bool") (not .NodeOnlyContainer)}}
@@ -254,6 +254,9 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context) string {
254254
itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
255255
itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "variableName")
256256
itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipVariableName", item.{{toGoName .TfName}}Variable.ValueString())
257+
{{- if .RequiresConstAndVar }}
258+
itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue", item.{{toGoName .TfName}}.Value{{.Type}}())
259+
{{end}}
257260
} else
258261
{{- end}} if item.{{toGoName .TfName}}.IsNull() {
259262
{{- if and (not .Mandatory) (not .ExcludeIgnore)}}
@@ -268,6 +271,9 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context) string {
268271
itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
269272
itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "constant")
270273
itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue", item.{{toGoName .TfName}}.Value{{.Type}}())
274+
{{- if and (.RequiresConstAndVar) (.Variable) }}
275+
itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipVariableName", item.{{toGoName .TfName}}Variable.Value{{.Type}}())
276+
{{end}}
271277
}
272278
{{- else if and (eq .Type "Bool") (not .NodeOnlyContainer)}}
273279
{{if .Variable}}
@@ -349,6 +355,9 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context) string {
349355
itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
350356
itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "variableName")
351357
itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipVariableName", childItem.{{toGoName .TfName}}Variable.ValueString())
358+
{{- if .RequiresConstAndVar }}
359+
itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue", childItem.{{toGoName .TfName}}.Value{{.Type}}())
360+
{{end}}
352361
} else
353362
{{- end}} if childItem.{{toGoName .TfName}}.IsNull() {
354363
{{- if and (not .Mandatory) (not .ExcludeIgnore)}}
@@ -363,6 +372,9 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context) string {
363372
itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
364373
itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "constant")
365374
itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue", childItem.{{toGoName .TfName}}.Value{{.Type}}())
375+
{{- if and (.RequiresConstAndVar) (.Variable) }}
376+
itemChildBody, _ = sjson.Set(itemChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipVariableName", childItem.{{toGoName .TfName}}Variable.Value{{.Type}}())
377+
{{end}}
366378
}
367379
{{- else if and (eq .Type "Bool") (not .NodeOnlyContainer)}}
368380
{{if .Variable}}
@@ -444,6 +456,9 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context) string {
444456
itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
445457
itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "variableName")
446458
itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipVariableName", childChildItem.{{toGoName .TfName}}Variable.ValueString())
459+
{{- if .RequiresConstAndVar }}
460+
itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue", childChildItem.{{toGoName .TfName}}.Value{{.Type}}())
461+
{{end}}
447462
} else
448463
{{- end}} if childChildItem.{{toGoName .TfName}}.IsNull() {
449464
{{- if and (not .Mandatory) (not .ExcludeIgnore)}}
@@ -458,6 +473,9 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context) string {
458473
itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipObjectType", "{{.ObjectType}}")
459474
itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipType", "constant")
460475
itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipValue", childChildItem.{{toGoName .TfName}}.Value{{.Type}}())
476+
{{- if and (.RequiresConstAndVar) (.Variable) }}
477+
itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}."+"vipVariableName", childChildItem.{{toGoName .TfName}}Variable.Value{{.Type}}())
478+
{{end}}
461479
}
462480
{{- else if and (eq .Type "Bool") (not .NodeOnlyContainer)}}
463481
{{if .Variable}}

0 commit comments

Comments
 (0)