service.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package show
  2. import (
  3. "time"
  4. "go-common/app/interface/main/app-resource/conf"
  5. adtdao "go-common/app/interface/main/app-resource/dao/audit"
  6. resdao "go-common/app/interface/main/app-resource/dao/resource"
  7. tabdao "go-common/app/interface/main/app-resource/dao/tab"
  8. "go-common/app/interface/main/app-resource/model/show"
  9. "go-common/app/interface/main/app-resource/model/tab"
  10. resource "go-common/app/service/main/resource/model"
  11. )
  12. // Service is showtab service.
  13. type Service struct {
  14. c *conf.Config
  15. //dao
  16. rdao *resdao.Dao
  17. tdao *tabdao.Dao
  18. adt *adtdao.Dao
  19. tick time.Duration
  20. tabCache map[string][]*show.Tab
  21. limitsCahce map[int64][]*resource.SideBarLimit
  22. menuCache []*tab.Menu
  23. abtestCache map[string]*resource.AbTest
  24. showTabMids map[int64]struct{}
  25. auditCache map[string]map[int]struct{} // audit mobi_app builds
  26. }
  27. // New new a showtab service.
  28. func New(c *conf.Config) (s *Service) {
  29. s = &Service{
  30. c: c,
  31. rdao: resdao.New(c),
  32. tdao: tabdao.New(c),
  33. adt: adtdao.New(c),
  34. tick: time.Duration(c.Tick),
  35. tabCache: map[string][]*show.Tab{},
  36. limitsCahce: map[int64][]*resource.SideBarLimit{},
  37. menuCache: []*tab.Menu{},
  38. abtestCache: map[string]*resource.AbTest{},
  39. showTabMids: map[int64]struct{}{},
  40. auditCache: map[string]map[int]struct{}{},
  41. }
  42. if err := s.loadCache(); err != nil {
  43. panic(err)
  44. }
  45. s.loadShowTabAids()
  46. go s.loadCacheproc()
  47. return
  48. }