Skip to content

Commit

Permalink
chore(template): update .template go-zero/model
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] committed Nov 18, 2024
1 parent 0f3a0ad commit c07b527
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions .template/go-zero/model/model-new.tpl
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
func new{{.upperStartCamelObject}}Model(conn sqlx.SqlConn, op ...opts.Opt[modelx.ModelOpts]) *default{{.upperStartCamelObject}}Model {
{{if .withCache}}o := opts.DefaultApply(op...){{end}}
o := opts.DefaultApply(op...)
var cachedConn sqlc.CachedConn
if len(o.CacheConf) > 0 {
cachedConn = sqlc.NewConn(conn, o.CacheConf, o.CacheOpts...)
}
if o.CachedConn != nil {
cachedConn = *o.CachedConn
}
return &default{{.upperStartCamelObject}}Model{
{{if .withCache}}cachedConn: sqlc.NewConn(conn, o.CacheConf, o.CacheOpts...),{{end}}
cachedConn: cachedConn,
conn: conn,
table: {{.table}},
}
}

}

0 comments on commit c07b527

Please sign in to comment.