dao.go 461 B

1234567891011121314151617181920212223242526272829303132333435
  1. package mysql
  2. import (
  3. "context"
  4. "go-common/app/admin/main/aegis/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 (d *Dao) Close() {
  22. d.db.Close()
  23. }
  24. // Ping dao ping
  25. func (d *Dao) Ping(c context.Context) error {
  26. return d.db.Ping(c)
  27. }