mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-03 16:00:25 +08:00
fix: base.app事务方法调整
This commit is contained in:
@@ -183,7 +183,7 @@ func (ai *AppImpl[T, R]) Tx(ctx context.Context, funcs ...func(context.Context)
|
||||
}
|
||||
|
||||
tx.Count--
|
||||
if tx.Count < 1 {
|
||||
if tx.Count == 0 {
|
||||
// 移除当前已执行完成的的数据库事务实例
|
||||
contextx.RmDb(ctx)
|
||||
}
|
||||
@@ -191,8 +191,8 @@ func (ai *AppImpl[T, R]) Tx(ctx context.Context, funcs ...func(context.Context)
|
||||
|
||||
for _, f := range funcs {
|
||||
err = f(dbCtx)
|
||||
if err != nil {
|
||||
tx.Count = 0
|
||||
if err != nil && tx.Count > 0 {
|
||||
tx.Count = 1
|
||||
txDb.Rollback()
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user