2020-08-19 10:41:19 +08:00
|
|
|
package template
|
2020-07-29 17:11:41 +08:00
|
|
|
|
2020-12-21 09:43:32 +08:00
|
|
|
import "fmt"
|
|
|
|
|
2021-02-26 16:11:47 +08:00
|
|
|
// Vars defines a template for var block in model
|
2022-05-23 09:12:06 +08:00
|
|
|
var Vars = fmt.Sprintf(
|
|
|
|
`
|
2020-07-29 17:11:41 +08:00
|
|
|
var (
|
2021-11-15 21:02:11 +08:00
|
|
|
{{.lowerStartCamelObject}}FieldNames = builder.RawFieldNames(&{{.upperStartCamelObject}}{}{{if .postgreSql}},true{{end}})
|
2020-08-19 10:41:19 +08:00
|
|
|
{{.lowerStartCamelObject}}Rows = strings.Join({{.lowerStartCamelObject}}FieldNames, ",")
|
2022-07-11 23:06:00 +08:00
|
|
|
{{.lowerStartCamelObject}}RowsExpectAutoSet = {{if .postgreSql}}strings.Join(stringx.Remove({{.lowerStartCamelObject}}FieldNames, {{if .autoIncrement}}"{{.originalPrimaryKey}}",{{end}} "%screate_time%s", "%supdate_time%s", "%screate_at%s", "%supdate_at%s"), ","){{else}}strings.Join(stringx.Remove({{.lowerStartCamelObject}}FieldNames, {{if .autoIncrement}}"{{.originalPrimaryKey}}",{{end}} "%screate_time%s", "%supdate_time%s", "%screate_at%s", "%supdate_at%s"), ","){{end}}
|
2022-05-23 09:12:06 +08:00
|
|
|
{{.lowerStartCamelObject}}RowsWithPlaceHolder = {{if .postgreSql}}builder.PostgreSqlJoin(stringx.Remove({{.lowerStartCamelObject}}FieldNames, "{{.originalPrimaryKey}}", "%screate_time%s", "%supdate_time%s", "%screate_at%s", "%supdate_at%s")){{else}}strings.Join(stringx.Remove({{.lowerStartCamelObject}}FieldNames, "{{.originalPrimaryKey}}", "%screate_time%s", "%supdate_time%s", "%screate_at%s", "%supdate_at%s"), "=?,") + "=?"{{end}}
|
2020-07-29 17:11:41 +08:00
|
|
|
|
2020-08-19 10:41:19 +08:00
|
|
|
{{if .withCache}}{{.cacheKeys}}{{end}}
|
2020-07-29 17:11:41 +08:00
|
|
|
)
|
2022-05-23 09:12:06 +08:00
|
|
|
`, "", "", "", "", "", "", "", "", // postgreSql mode
|
|
|
|
"`", "`", "`", "`", "`", "`", "`", "`",
|
|
|
|
"", "", "", "", "", "", "", "", // postgreSql mode
|
|
|
|
"`", "`", "`", "`", "`", "`", "`", "`",
|
|
|
|
)
|