From b0573af9a9ce022f021bfc8ede4bb227212572d2 Mon Sep 17 00:00:00 2001 From: anqiansong Date: Mon, 15 Nov 2021 21:02:11 +0800 Subject: [PATCH] Update template (#1243) --- tools/goctl/model/sql/template/import.go | 4 ++-- tools/goctl/model/sql/template/vars.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/goctl/model/sql/template/import.go b/tools/goctl/model/sql/template/import.go index b5af6252..3dcf0649 100644 --- a/tools/goctl/model/sql/template/import.go +++ b/tools/goctl/model/sql/template/import.go @@ -8,11 +8,11 @@ var ( "strings" {{if .time}}"time"{{end}} + "github.com/tal-tech/go-zero/core/stores/builder" "github.com/tal-tech/go-zero/core/stores/cache" "github.com/tal-tech/go-zero/core/stores/sqlc" "github.com/tal-tech/go-zero/core/stores/sqlx" "github.com/tal-tech/go-zero/core/stringx" - "github.com/tal-tech/go-zero/core/stores/builderx" ) ` // ImportsNoCache defines a import template for model in normal case @@ -22,10 +22,10 @@ var ( "strings" {{if .time}}"time"{{end}} + "github.com/tal-tech/go-zero/core/stores/builder" "github.com/tal-tech/go-zero/core/stores/sqlc" "github.com/tal-tech/go-zero/core/stores/sqlx" "github.com/tal-tech/go-zero/core/stringx" - "github.com/tal-tech/go-zero/core/stores/builderx" ) ` ) diff --git a/tools/goctl/model/sql/template/vars.go b/tools/goctl/model/sql/template/vars.go index d56be3b2..f5309cfa 100644 --- a/tools/goctl/model/sql/template/vars.go +++ b/tools/goctl/model/sql/template/vars.go @@ -5,10 +5,10 @@ import "fmt" // Vars defines a template for var block in model var Vars = fmt.Sprintf(` var ( - {{.lowerStartCamelObject}}FieldNames = builderx.RawFieldNames(&{{.upperStartCamelObject}}{}{{if .postgreSql}},true{{end}}) + {{.lowerStartCamelObject}}FieldNames = builder.RawFieldNames(&{{.upperStartCamelObject}}{}{{if .postgreSql}},true{{end}}) {{.lowerStartCamelObject}}Rows = strings.Join({{.lowerStartCamelObject}}FieldNames, ",") {{.lowerStartCamelObject}}RowsExpectAutoSet = {{if .postgreSql}}strings.Join(stringx.Remove({{.lowerStartCamelObject}}FieldNames, {{if .autoIncrement}}"{{.originalPrimaryKey}}",{{end}} "%screate_time%s", "%supdate_time%s"), ","){{else}}strings.Join(stringx.Remove({{.lowerStartCamelObject}}FieldNames, {{if .autoIncrement}}"{{.originalPrimaryKey}}",{{end}} "%screate_time%s", "%supdate_time%s"), ","){{end}} - {{.lowerStartCamelObject}}RowsWithPlaceHolder = {{if .postgreSql}}builderx.PostgreSqlJoin(stringx.Remove({{.lowerStartCamelObject}}FieldNames, "{{.originalPrimaryKey}}", "%screate_time%s", "%supdate_time%s")){{else}}strings.Join(stringx.Remove({{.lowerStartCamelObject}}FieldNames, "{{.originalPrimaryKey}}", "%screate_time%s", "%supdate_time%s"), "=?,") + "=?"{{end}} + {{.lowerStartCamelObject}}RowsWithPlaceHolder = {{if .postgreSql}}builder.PostgreSqlJoin(stringx.Remove({{.lowerStartCamelObject}}FieldNames, "{{.originalPrimaryKey}}", "%screate_time%s", "%supdate_time%s")){{else}}strings.Join(stringx.Remove({{.lowerStartCamelObject}}FieldNames, "{{.originalPrimaryKey}}", "%screate_time%s", "%supdate_time%s"), "=?,") + "=?"{{end}} {{if .withCache}}{{.cacheKeys}}{{end}} )