binder.go 764 B

1234567891011121314151617181920212223242526272829303132333435
  1. package binding
  2. import (
  3. "git.sxidc.com/go-framework/baize/api"
  4. "git.sxidc.com/go-framework/baize/infrastructure"
  5. "git.sxidc.com/go-framework/baize/infrastructure/database"
  6. )
  7. type Binder struct {
  8. router api.Router
  9. i *infrastructure.Infrastructure
  10. }
  11. func NewBinder(router api.Router, i *infrastructure.Infrastructure) *Binder {
  12. return &Binder{
  13. router: router,
  14. i: i,
  15. }
  16. }
  17. const (
  18. DBExecutorOperations = "operations"
  19. DBExecutorDataService = "data_service"
  20. )
  21. func (binder *Binder) ChooseDBExecutor(dataExecutorType string) database.Executor {
  22. switch dataExecutorType {
  23. case DBExecutorOperations:
  24. return binder.i.DBOperations()
  25. case DBExecutorDataService:
  26. return binder.i.DataService()
  27. default:
  28. return binder.i.DBOperations()
  29. }
  30. }