dao.go 502 B

123456789101112131415161718192021222324252627282930313233343536
  1. package card
  2. import (
  3. "context"
  4. "go-common/app/service/main/up/conf"
  5. "go-common/app/service/main/up/dao/global"
  6. "go-common/library/database/sql"
  7. )
  8. // Dao is redis dao.
  9. type Dao struct {
  10. c *conf.Config
  11. db *sql.DB
  12. }
  13. // New fn
  14. func New(c *conf.Config) (d *Dao) {
  15. d = &Dao{
  16. c: c,
  17. db: global.GetUpCrmDB(),
  18. }
  19. return d
  20. }
  21. // Close fn
  22. func (d *Dao) Close() {
  23. if d.db != nil {
  24. d.db.Close()
  25. }
  26. }
  27. // Ping ping cpdb
  28. func (d *Dao) Ping(c context.Context) (err error) {
  29. return d.db.Ping(c)
  30. }