dao.go 813 B

12345678910111213141516171819202122232425262728293031323334
  1. package bnj
  2. import (
  3. "time"
  4. "go-common/app/job/main/activity/conf"
  5. "go-common/library/cache/memcache"
  6. "go-common/library/net/http/blademaster"
  7. )
  8. // Dao .
  9. type Dao struct {
  10. c *conf.Config
  11. client *blademaster.Client
  12. mc *memcache.Pool
  13. broadcastURL string
  14. messageURL string
  15. timeFinishExpire int32
  16. lessTimeExpire int32
  17. }
  18. // New .
  19. func New(c *conf.Config) *Dao {
  20. d := &Dao{
  21. c: c,
  22. client: blademaster.NewClient(c.HTTPClient),
  23. mc: memcache.NewPool(c.Memcache.Like),
  24. }
  25. d.broadcastURL = d.c.Host.APICo + _broadURL
  26. d.messageURL = d.c.Host.MsgCo + _messageURL
  27. d.timeFinishExpire = int32(time.Duration(c.Memcache.TimeFinishExpire) / time.Second)
  28. d.lessTimeExpire = int32(time.Duration(c.Memcache.LessTimeExpire) / time.Second)
  29. return d
  30. }