dao.go 771 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/job/main/passport-auth/conf"
  5. xsql "go-common/library/database/sql"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. // Dao dao
  9. type Dao struct {
  10. c *conf.Config
  11. db *xsql.DB
  12. olddb *xsql.DB
  13. // httpClient
  14. httpClient *bm.Client
  15. }
  16. // New init mysql db
  17. func New(c *conf.Config) (dao *Dao) {
  18. dao = &Dao{
  19. c: c,
  20. db: xsql.NewMySQL(c.MySQL),
  21. olddb: xsql.NewMySQL(c.OldMySQL),
  22. // httpClient
  23. httpClient: bm.NewClient(c.HTTPClientConfig),
  24. }
  25. return
  26. }
  27. // Close close the resource.
  28. func (d *Dao) Close() {
  29. d.db.Close()
  30. d.olddb.Close()
  31. }
  32. // Ping dao ping
  33. func (d *Dao) Ping(c context.Context) error {
  34. return d.pingMC(c)
  35. }
  36. // pingMc ping
  37. func (d *Dao) pingMC(c context.Context) (err error) {
  38. return
  39. }