feat: add table vars to model provider

This commit is contained in:
Rogee
2025-05-26 10:13:30 +08:00
parent 906858dbd6
commit 2b0ee0e61c
2 changed files with 24 additions and 13 deletions

View File

@@ -6,6 +6,11 @@ import (
"context"
"database/sql"
{{ if gt (len .) 0 }}
"{{ (index . 0).PkgName }}/database/table"
{{ end }}
"go.ipao.vip/atom"
"go.ipao.vip/atom/container"
"go.ipao.vip/atom/contracts"
@@ -33,7 +38,13 @@ func CondJoin(cond Cond, conds ...Cond) []Cond {
return append([]Cond{cond}, conds...)
}
// tables
{{- range . }}
var tbl{{.PascalTable}} = table.{{.PascalTable}}
{{- end }}
// models
var db *sql.DB
{{- range . }}
func {{.PascalTable}}Model() *{{.PascalTable}} { return &{{.PascalTable}}{} }