- rollback when panic.

This commit is contained in:
gazebo
2018-09-17 16:18:04 +08:00
parent 9a6808e9dd
commit 8e85a240e8
3 changed files with 42 additions and 0 deletions

View File

@@ -184,6 +184,12 @@ func GetStores(keyword string, params map[string]interface{}, offset, pageSize i
retVal = &StoresInfo{}
db := dao.GetDB()
dao.Begin(db)
defer func() {
if r := recover(); r != nil {
dao.Rollback(db)
panic(r)
}
}()
if err = dao.GetRows(db, &retVal.Stores, sql, sqlParams...); err == nil {
countInfo := &struct{ Ct int }{}
if err = dao.GetRow(db, countInfo, "SELECT FOUND_ROWS() ct"); err == nil {