goctl model reactor (#15)
* 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
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
package sqltemplate
|
||||
package template
|
||||
|
||||
var Delete = `
|
||||
func (m *{{.upperObject}}Model) Delete({{.lowerPrimaryKey}} {{.dataType}}) error {
|
||||
{{if .containsCache}}{{if .isNotPrimaryKey}}data,err:=m.FindOne({{.lowerPrimaryKey}})
|
||||
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 .isNotPrimaryKey}}={{else}}:={{end}} m.Exec(func(conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||
query := ` + "`" + `delete from ` + "` +" + ` m.table + ` + " `" + ` where {{.snakePrimaryKey}} = ?` + "`" + `
|
||||
return conn.Exec(query, {{.lowerPrimaryKey}})
|
||||
}, {{.keyValues}}){{else}}query := ` + "`" + `delete from ` + "` +" + ` m.table + ` + " `" + ` where {{.snakePrimaryKey}} = ?` + "`" + `
|
||||
_,err:=m.ExecNoCache(query, {{.lowerPrimaryKey}}){{end}}
|
||||
_, 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
|
||||
}
|
||||
`
|
||||
|
||||
Reference in New Issue
Block a user