mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-25 02:08:44 +08:00
d21d770b5b
* reactor sql generation
* reactor sql generation
* add console & example
* optimize unit test & add document
* modify default config
* remove test file
* Revert "remove test file"
This reverts commit 81041f9e
* fix stringx.go & optimize example
* remove unused code
18 lines
798 B
Go
18 lines
798 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
|
|
}
|
|
`
|