mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-24 18:00:24 +08:00
3a4e1cbb33
* add execute files * add protoc-osx * add rpc generation * add rpc generation * add: rpc template generation * optimize gomod cache * add README.md * format error * reactor templatex.go * update project.go & README.md * fix bug: miss time import
19 lines
800 B
Go
19 lines
800 B
Go
package template
|
|
|
|
var Delete = `
|
|
func (m *{{.upperStartCamelObject}}Model) Delete({{.lowerStartCamelPrimaryKey}} {{.dataType}}) error {
|
|
{{if .withCache}}{{if .containsIndexCache}}data, err:=m.FindOne({{.lowerStartCamelPrimaryKey}})
|
|
if err!=nil{
|
|
return err
|
|
}{{end}}
|
|
|
|
{{.keys}}
|
|
_, err {{if .containsIndexCache}}={{else}}:={{end}} m.Exec(func(conn sqlx.SqlConn) (result sql.Result, err error) {
|
|
query := ` + "`" + `delete from ` + "` +" + ` m.table + ` + " `" + ` where {{.originalPrimaryKey}} = ?` + "`" + `
|
|
return conn.Exec(query, {{.lowerStartCamelPrimaryKey}})
|
|
}, {{.keyValues}}){{else}}query := ` + "`" + `delete from ` + "` +" + ` m.table + ` + " `" + ` where {{.originalPrimaryKey}} = ?` + "`" + `
|
|
_,err:=m.conn.Exec(query, {{.lowerStartCamelPrimaryKey}}){{end}}
|
|
return err
|
|
}
|
|
`
|