From e5546edbbbc9a1efdc3805bfe5c85f674bfb5077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=93=AD=E6=98=95?= <715557344@qq.com> Date: Mon, 9 Dec 2024 18:33:35 +0800 Subject: [PATCH] Update --- tools/goctl/model/sql/gen/new.go | 3 +++ tools/goctl/model/sql/template/tpl/model-new.tpl | 2 ++ tools/goctl/model/sql/template/tpl/types.tpl | 2 ++ 3 files changed, 7 insertions(+) diff --git a/tools/goctl/model/sql/gen/new.go b/tools/goctl/model/sql/gen/new.go index 96810aa379921..fcce885bf034e 100644 --- a/tools/goctl/model/sql/gen/new.go +++ b/tools/goctl/model/sql/gen/new.go @@ -16,6 +16,7 @@ func genNew(table Table, withCache, postgreSql bool) (string, error) { t := fmt.Sprintf(`"%s"`, wrapWithRawString(table.Name.Source(), postgreSql)) primaryKey := fmt.Sprintf(`"%s"`, table.PrimaryKey.Field.Name.Source()) + keyType := fmt.Sprintf(`"%s"`, table.PrimaryKey.DataType) if postgreSql { t = "`" + fmt.Sprintf(`"%s"."%s"`, table.Db.Source(), table.Name.Source()) + "`" } @@ -25,6 +26,8 @@ func genNew(table Table, withCache, postgreSql bool) (string, error) { Execute(map[string]any{ "table": t, "primaryKey": primaryKey, + "incrementing": table.PrimaryKey.AutoIncrement, + "keyType": keyType, "withCache": withCache, "upperStartCamelObject": table.Name.ToCamel(), "data": table, diff --git a/tools/goctl/model/sql/template/tpl/model-new.tpl b/tools/goctl/model/sql/template/tpl/model-new.tpl index 575a6023fdf1e..646e74e1d28ec 100644 --- a/tools/goctl/model/sql/template/tpl/model-new.tpl +++ b/tools/goctl/model/sql/template/tpl/model-new.tpl @@ -3,6 +3,8 @@ func new{{.upperStartCamelObject}}Model(conn sqlx.SqlConn{{if .withCache}}, c ca {{if .withCache}}CachedConn: sqlc.NewConn(conn, c, opts...){{else}}conn:conn{{end}}, table: {{.table}}, primaryKey: {{.primaryKey}}, + incrementing: {{.incrementing}}, + keyType: {{.keyType}}, } } diff --git a/tools/goctl/model/sql/template/tpl/types.tpl b/tools/goctl/model/sql/template/tpl/types.tpl index ceb3d65baad4b..de40b02fdb1da 100644 --- a/tools/goctl/model/sql/template/tpl/types.tpl +++ b/tools/goctl/model/sql/template/tpl/types.tpl @@ -7,6 +7,8 @@ type ( {{if .withCache}}sqlc.CachedConn{{else}}conn sqlx.SqlConn{{end}} table string primaryKey string + incrementing bool + keyType string } {{.upperStartCamelObject}} struct {