dao.go 649 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package manager
  2. import (
  3. "context"
  4. "go-common/app/admin/main/videoup/conf"
  5. "go-common/library/database/sql"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. // Dao is redis dao.
  9. type Dao struct {
  10. c *conf.Config
  11. // db
  12. managerDB *sql.DB
  13. httpClient *bm.Client
  14. }
  15. // New new a dao.
  16. func New(c *conf.Config) (d *Dao) {
  17. d = &Dao{
  18. c: c,
  19. managerDB: sql.NewMySQL(c.DB.Manager),
  20. httpClient: bm.NewClient(c.HTTPClient.Read),
  21. }
  22. return d
  23. }
  24. // Close close.
  25. func (d *Dao) Close() {
  26. if d.managerDB != nil {
  27. d.managerDB.Close()
  28. }
  29. }
  30. // Ping ping cpdb
  31. func (d *Dao) Ping(c context.Context) (err error) {
  32. return d.managerDB.Ping(c)
  33. }