goctl added

This commit is contained in:
kim
2020-07-29 17:11:41 +08:00
parent b1975d29a7
commit 121323b8c3
142 changed files with 10690 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
package sqltemplate
var Delete = `
func (m *{{.upperObject}}Model) Delete({{.lowerPrimaryKey}} {{.dataType}}) error {
{{if .containsCache}}{{if .isNotPrimaryKey}}data,err:=m.FindOne({{.lowerPrimaryKey}})
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}}
return err
}
`