dao.go 709 B

123456789101112131415161718192021222324252627282930313233
  1. package push
  2. import (
  3. appres "go-common/app/interface/main/app-resource/api/v1"
  4. "go-common/app/job/main/appstatic/conf"
  5. "go-common/library/cache/redis"
  6. xsql "go-common/library/database/sql"
  7. bm "go-common/library/net/http/blademaster"
  8. )
  9. // Dao .
  10. type Dao struct {
  11. c *conf.Config
  12. db *xsql.DB
  13. client *bm.Client
  14. redis *redis.Pool
  15. appresCli appres.AppResourceClient
  16. }
  17. // New creates a dao instance.
  18. func New(c *conf.Config) (d *Dao) {
  19. d = &Dao{
  20. c: c,
  21. db: xsql.NewMySQL(c.MySQL),
  22. client: bm.NewClient(c.HTTPClient),
  23. redis: redis.NewPool(c.Redis),
  24. }
  25. var err error
  26. if d.appresCli, err = appres.NewClient(c.AppresClient); err != nil {
  27. panic(err)
  28. }
  29. return
  30. }