2020-08-19 10:41:19 +08:00
|
|
|
package template
|
2020-07-29 17:11:41 +08:00
|
|
|
|
|
|
|
var Insert = `
|
2020-10-21 14:59:35 +08:00
|
|
|
func (m *{{.upperStartCamelObject}}Model) Insert(data {{.upperStartCamelObject}}) (sql.Result,error) {
|
2020-10-11 21:55:44 +08:00
|
|
|
{{if .withCache}}{{if .containsIndexCache}}{{.keys}}
|
2020-10-21 14:59:35 +08:00
|
|
|
ret, err := m.Exec(func(conn sqlx.SqlConn) (result sql.Result, err error) {
|
2020-10-11 21:55:44 +08:00
|
|
|
query := ` + "`" + `insert into ` + "`" + ` + m.table + ` + "` (` + " + `{{.lowerStartCamelObject}}RowsExpectAutoSet` + " + `) values ({{.expression}})` " + `
|
|
|
|
return conn.Exec(query, {{.expressionValues}})
|
|
|
|
}, {{.keyValues}}){{else}}query := ` + "`" + `insert into ` + "`" + ` + m.table + ` + "` (` + " + `{{.lowerStartCamelObject}}RowsExpectAutoSet` + " + `) values ({{.expression}})` " + `
|
2020-10-21 14:59:35 +08:00
|
|
|
ret,err:=m.ExecNoCache(query, {{.expressionValues}})
|
2020-10-11 21:55:44 +08:00
|
|
|
{{end}}{{else}}query := ` + "`" + `insert into ` + "`" + ` + m.table + ` + "` (` + " + `{{.lowerStartCamelObject}}RowsExpectAutoSet` + " + `) values ({{.expression}})` " + `
|
2020-10-21 14:59:35 +08:00
|
|
|
ret,err:=m.conn.Exec(query, {{.expressionValues}}){{end}}
|
|
|
|
return ret,err
|
2020-07-29 17:11:41 +08:00
|
|
|
}
|
|
|
|
`
|