mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-29 04:27:17 +00:00
fix🐛: import "time" in a generated model only for fields it declares
The model template imported "time" for any queryable time.Time column, though whether a column is queryable only shapes the DTO. A queryable created_at, which the model takes from models.ModelTime rather than declaring, left the import unused and the generated package failed to compile.
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
{{- /*
|
||||
The model declares a time.Time field for every such column except the
|
||||
three models.ModelTime supplies. Whether a column is queryable is the
|
||||
DTO's business, not the model's: counting it here imported "time" for a
|
||||
queryable created_at that the model never declares.
|
||||
*/ -}}
|
||||
{{- $bb := false -}}
|
||||
{{- range .Columns -}}
|
||||
{{- $z := .IsQuery -}}
|
||||
{{- if ($z) -}}
|
||||
{{- if eq .GoType "time.Time" -}}{{- $bb = true -}}{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- range .Columns -}}
|
||||
{{- if eq .GoField "CreatedAt" -}}
|
||||
{{- else if eq .GoField "UpdatedAt" -}}
|
||||
{{- else if eq .GoField "DeletedAt" -}}
|
||||
|
||||
Reference in New Issue
Block a user