dao.go 565 B

123456789101112131415161718192021222324252627282930313233
  1. package dao
  2. import (
  3. "go-common/app/service/main/msm/conf"
  4. "go-common/library/database/sql"
  5. bm "go-common/library/net/http/blademaster"
  6. )
  7. // Dao dao.
  8. type Dao struct {
  9. client *bm.Client
  10. db *sql.DB
  11. treeHost string
  12. platformID string
  13. }
  14. // New new dao.
  15. func New(c *conf.Config) *Dao {
  16. d := &Dao{
  17. db: sql.NewMySQL(c.Mysql),
  18. client: bm.NewClient(c.HTTPClient),
  19. treeHost: c.Tree.Host,
  20. platformID: c.Tree.PlatformID,
  21. }
  22. return d
  23. }
  24. // Close close mysql resource.
  25. func (d *Dao) Close() {
  26. if d.db != nil {
  27. d.db.Close()
  28. }
  29. }