GAAS GFrame项目web后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
735 B

  1. package container
  2. import (
  3. "fmt"
  4. "github.com/go-xorm/xorm"
  5. )
  6. type DefaultTransactionHandlerFactory struct {
  7. // xorm.Engine
  8. engine *xorm.Engine
  9. }
  10. // 创建事务句柄工厂
  11. // 参数:
  12. // 1.xorm.Engine
  13. // 返回值:
  14. // 1.事务句柄工厂
  15. // 异常:
  16. // 1.xorm.Engine不能为空!
  17. func NewDefaultTransactionHandlerFactory(engine *xorm.Engine) *DefaultTransactionHandlerFactory {
  18. if engine == nil {
  19. panic(fmt.Sprintf("xorm.Engine不能为空!"))
  20. }
  21. return &DefaultTransactionHandlerFactory{engine}
  22. }
  23. // @Reference LAPP_GAAS_GFrame_BACKEND/container/TransactionHandlerFactory.Create
  24. func (impl *DefaultTransactionHandlerFactory) Create() (TransactionHandler, error) {
  25. return NewTransactionHandler(impl.engine.NewSession())
  26. }