dao.go 664 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package watermark
  2. import (
  3. "context"
  4. "go-common/app/interface/main/creative/conf"
  5. "go-common/library/database/sql"
  6. httpx "go-common/library/net/http/blademaster"
  7. )
  8. // Dao define
  9. type Dao struct {
  10. c *conf.Config
  11. db *sql.DB
  12. // http client
  13. client *httpx.Client
  14. genWm string
  15. }
  16. // New init dao
  17. func New(c *conf.Config) (d *Dao) {
  18. d = &Dao{
  19. c: c,
  20. db: sql.NewMySQL(c.DB.Creative),
  21. // http client
  22. client: httpx.NewClient(c.HTTPClient.Normal),
  23. genWm: c.Host.API + _genWm,
  24. }
  25. return
  26. }
  27. // Ping db
  28. func (d *Dao) Ping(c context.Context) (err error) {
  29. return d.db.Ping(c)
  30. }
  31. // Close db
  32. func (d *Dao) Close() (err error) {
  33. return d.db.Close()
  34. }