diff --git a/tools/goctl/internal/version/version.go b/tools/goctl/internal/version/version.go index 77f93077..103fe713 100644 --- a/tools/goctl/internal/version/version.go +++ b/tools/goctl/internal/version/version.go @@ -6,7 +6,7 @@ import ( ) // BuildVersion is the version of goctl. -const BuildVersion = "1.5.2" +const BuildVersion = "1.5.3" var tag = map[string]int{"pre-alpha": 0, "alpha": 1, "pre-bata": 2, "beta": 3, "released": 4, "": 5} diff --git a/tools/goctl/model/sql/template/tpl/model-new.tpl b/tools/goctl/model/sql/template/tpl/model-new.tpl index 76598ecd..1743e578 100644 --- a/tools/goctl/model/sql/template/tpl/model-new.tpl +++ b/tools/goctl/model/sql/template/tpl/model-new.tpl @@ -4,3 +4,10 @@ func new{{.upperStartCamelObject}}Model(conn sqlx.SqlConn{{if .withCache}}, c ca table: {{.table}}, } } + +func (m *default{{.upperStartCamelObject}}Model) withSession(session sqlx.Session) *default{{.upperStartCamelObject}}Model { + return &default{{.upperStartCamelObject}}Model{ + {{if .withCache}}CachedConn:m.CachedConn.WithSession(session){{else}}conn:sqlx.NewSqlConnFromSession(session){{end}}, + table: {{.table}}, + } +}