dao.go 690 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/admin/main/esports/conf"
  5. "go-common/library/database/elastic"
  6. "go-common/library/database/orm"
  7. bm "go-common/library/net/http/blademaster"
  8. "github.com/jinzhu/gorm"
  9. )
  10. const _esports = "esports"
  11. // Dao .
  12. type Dao struct {
  13. c *conf.Config
  14. DB *gorm.DB
  15. Elastic *elastic.Elastic
  16. // client
  17. replyClient *bm.Client
  18. }
  19. // New .
  20. func New(c *conf.Config) (d *Dao) {
  21. d = &Dao{
  22. // conf
  23. c: c,
  24. // db
  25. DB: orm.NewMySQL(c.ORM),
  26. // elastic
  27. Elastic: elastic.NewElastic(nil),
  28. replyClient: bm.NewClient(c.HTTPReply),
  29. }
  30. return
  31. }
  32. // Ping .
  33. func (d *Dao) Ping(c context.Context) error {
  34. return d.DB.DB().PingContext(c)
  35. }