b_trans.go 409 B

1234567891011121314151617181920212223
  1. package internal
  2. import (
  3. "context"
  4. "gxt-file-server/app/model"
  5. )
  6. // NewTrans 创建事务管理实例
  7. func NewTrans(trans model.ITrans) *Trans {
  8. return &Trans{
  9. TransModel: trans,
  10. }
  11. }
  12. // Trans 事务管理
  13. type Trans struct {
  14. TransModel model.ITrans
  15. }
  16. // Exec 执行事务
  17. func (a *Trans) Exec(ctx context.Context, fn func(context.Context) error) error {
  18. return ExecTrans(ctx, a.TransModel, fn)
  19. }