mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-25 02:08:44 +08:00
607fc3297a
* replace quote * rpc disable override main.go * reactor template * add model flag -style * add model flag -style * reactor model template name of error
16 lines
872 B
Go
16 lines
872 B
Go
package template
|
|
|
|
var Insert = `
|
|
func (m *{{.upperStartCamelObject}}Model) Insert(data {{.upperStartCamelObject}}) (sql.Result,error) {
|
|
{{if .withCache}}{{if .containsIndexCache}}{{.keys}}
|
|
ret, err := m.Exec(func(conn sqlx.SqlConn) (result sql.Result, err error) {
|
|
query := fmt.Sprintf("insert into %s (%s) values ({{.expression}})", m.table, {{.lowerStartCamelObject}}RowsExpectAutoSet)
|
|
return conn.Exec(query, {{.expressionValues}})
|
|
}, {{.keyValues}}){{else}}query := fmt.Sprintf("insert into %s (%s) values ({{.expression}})", m.table, {{.lowerStartCamelObject}}RowsExpectAutoSet)
|
|
ret,err:=m.ExecNoCache(query, {{.expressionValues}})
|
|
{{end}}{{else}}query := fmt.Sprintf("insert into %s (%s) values ({{.expression}})", m.table, {{.lowerStartCamelObject}}RowsExpectAutoSet)
|
|
ret,err:=m.conn.Exec(query, {{.expressionValues}}){{end}}
|
|
return ret,err
|
|
}
|
|
`
|