dao.go 682 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package manager
  2. import (
  3. "context"
  4. "go-common/app/job/main/videoup-report/conf"
  5. xsql "go-common/library/database/sql"
  6. "go-common/library/log"
  7. )
  8. // Dao is manager dao.
  9. type Dao struct {
  10. c *conf.Config
  11. db *xsql.DB
  12. }
  13. // New new a manager dao.
  14. func New(c *conf.Config) (d *Dao) {
  15. d = &Dao{
  16. c: c,
  17. db: xsql.NewMySQL(c.DB.Manager),
  18. }
  19. return d
  20. }
  21. //Ping ping
  22. func (d *Dao) Ping(c context.Context) (err error) {
  23. if err = d.db.Ping(c); err != nil {
  24. log.Error("manager ping error(%v)", err)
  25. }
  26. return
  27. }
  28. //Close close
  29. func (d *Dao) Close() (err error) {
  30. if d.db != nil {
  31. err = d.db.Close()
  32. }
  33. if err != nil {
  34. log.Error("manager close error(%v)", err)
  35. }
  36. return
  37. }