Update template (#1243)
This commit is contained in:
@@ -8,11 +8,11 @@ var (
|
|||||||
"strings"
|
"strings"
|
||||||
{{if .time}}"time"{{end}}
|
{{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/cache"
|
||||||
"github.com/tal-tech/go-zero/core/stores/sqlc"
|
"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/stores/sqlx"
|
||||||
"github.com/tal-tech/go-zero/core/stringx"
|
"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
|
// ImportsNoCache defines a import template for model in normal case
|
||||||
@@ -22,10 +22,10 @@ var (
|
|||||||
"strings"
|
"strings"
|
||||||
{{if .time}}"time"{{end}}
|
{{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/sqlc"
|
||||||
"github.com/tal-tech/go-zero/core/stores/sqlx"
|
"github.com/tal-tech/go-zero/core/stores/sqlx"
|
||||||
"github.com/tal-tech/go-zero/core/stringx"
|
"github.com/tal-tech/go-zero/core/stringx"
|
||||||
"github.com/tal-tech/go-zero/core/stores/builderx"
|
|
||||||
)
|
)
|
||||||
`
|
`
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import "fmt"
|
|||||||
// Vars defines a template for var block in model
|
// Vars defines a template for var block in model
|
||||||
var Vars = fmt.Sprintf(`
|
var Vars = fmt.Sprintf(`
|
||||||
var (
|
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}}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}}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}}
|
{{if .withCache}}{{.cacheKeys}}{{end}}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user