service.go 854 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package thirdp
  2. import (
  3. "context"
  4. "go-common/app/interface/main/tv/conf"
  5. "go-common/app/interface/main/tv/dao/archive"
  6. cmsDao "go-common/app/interface/main/tv/dao/cms"
  7. "go-common/app/interface/main/tv/dao/thirdp"
  8. tpMdl "go-common/app/interface/main/tv/model/thirdp"
  9. xcache "go-common/library/cache"
  10. )
  11. var (
  12. ctx = context.Background()
  13. cache *xcache.Cache
  14. )
  15. func init() {
  16. cache = xcache.New(1, 1024)
  17. }
  18. // Service .
  19. type Service struct {
  20. dao *thirdp.Dao
  21. cmsDao *cmsDao.Dao
  22. arcDao *archive.Dao
  23. conf *conf.Config
  24. mangoRecom []*tpMdl.MangoParams // mango recom data
  25. }
  26. // New .
  27. func New(c *conf.Config) *Service {
  28. srv := &Service{
  29. // dao
  30. dao: thirdp.New(c),
  31. cmsDao: cmsDao.New(c),
  32. arcDao: archive.New(c),
  33. // config
  34. conf: c,
  35. }
  36. go srv.mangorproc() // load mango recom data
  37. srv.mangoR()
  38. return srv
  39. }