dao.go 462 B

123456789101112131415161718192021222324252627282930313233
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/infra/notify/conf"
  5. xsql "go-common/library/database/sql"
  6. )
  7. // Dao dao
  8. type Dao struct {
  9. c *conf.Config
  10. db *xsql.DB
  11. }
  12. // New init mysql db
  13. func New(c *conf.Config) (dao *Dao) {
  14. dao = &Dao{
  15. c: c,
  16. db: xsql.NewMySQL(c.MySQL),
  17. }
  18. return
  19. }
  20. // Close close the resource.
  21. func (dao *Dao) Close() {
  22. dao.db.Close()
  23. }
  24. // Ping dao ping
  25. func (dao *Dao) Ping(c context.Context) error {
  26. return dao.db.Ping(c)
  27. }