Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
wubin48435 committed Apr 30, 2024
1 parent 4829735 commit 208178f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions toolkit/gormgen/generator.go
Expand Up @@ -790,6 +790,7 @@ func (g *Generator) generateModelFile() error {
funcMap["convert"] = func(s string) string {
return strings.ReplaceAll(s, "time.Time", "customtypes.Time")
}
funcMap["contains"] = strings.Contains
t, err := template.New(tmpl.Model).Funcs(funcMap).Parse(tmpl.Model)
if err != nil {
errChan <- err
Expand Down
4 changes: 4 additions & 0 deletions toolkit/gormgen/internal/template/model.go
Expand Up @@ -21,11 +21,15 @@ import (
{{if .TableName -}}var TableName{{.ModelStructName}} string{{- end}}
func init() {
{{- if contains .TableName "." }}
TableName{{.ModelStructName}} = "{{.TableName}}"
{{- else }}
if stringutils.IsNotEmpty(config.G_Config.Db.Name) {
TableName{{.ModelStructName}} = fmt.Sprintf("%s.{{.TableName}}", config.G_Config.Db.Name)
} else {
TableName{{.ModelStructName}} = "{{.TableName}}"
}
{{- end }}
}
// {{.ModelStructName}} {{.StructComment}}
Expand Down

0 comments on commit 208178f

Please sign in to comment.