manager.go 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. package channel
  2. import (
  3. "context"
  4. "go-common/app/interface/main/app-card/model"
  5. "go-common/app/interface/main/app-card/model/card/live"
  6. "go-common/app/interface/main/app-card/model/card/operate"
  7. )
  8. func (s *Service) convergeCard2(c context.Context, limit int, ids ...int64) (cardm map[int64]*operate.Card, aids, roomIDs, metaIDs []int64) {
  9. if len(ids) == 0 {
  10. return
  11. }
  12. cardm = make(map[int64]*operate.Card, len(ids))
  13. for i, id := range ids {
  14. if o, ok := s.convergeCardCache[id]; ok {
  15. card := &operate.Card{}
  16. card.FromConverge(o)
  17. cardm[id] = card
  18. for _, item := range card.Items {
  19. switch item.Goto {
  20. case model.GotoAv:
  21. if item.ID != 0 {
  22. aids = append(aids, item.ID)
  23. }
  24. case model.GotoLive:
  25. if item.ID != 0 {
  26. roomIDs = append(roomIDs, item.ID)
  27. }
  28. case model.GotoArticle:
  29. if item.ID != 0 {
  30. metaIDs = append(metaIDs, item.ID)
  31. }
  32. }
  33. if i == limit-1 {
  34. break
  35. }
  36. }
  37. }
  38. }
  39. return
  40. }
  41. func (s *Service) downloadCard(c context.Context, ids ...int64) (cardm map[int64]*operate.Card) {
  42. if len(ids) == 0 {
  43. return
  44. }
  45. cardm = make(map[int64]*operate.Card, len(ids))
  46. for _, id := range ids {
  47. if o, ok := s.gameDownloadCache[id]; ok {
  48. card := &operate.Card{}
  49. card.FromDownload(o)
  50. cardm[id] = card
  51. }
  52. }
  53. return
  54. }
  55. func (s *Service) subscribeCard(c context.Context, ids ...int64) (cardm map[int64]*operate.Card, upIDs, tids []int64) {
  56. if len(ids) == 0 {
  57. return
  58. }
  59. cardm = make(map[int64]*operate.Card, len(ids))
  60. for _, id := range ids {
  61. if o, ok := s.upCardCache[id]; ok {
  62. card := &operate.Card{}
  63. card.FromFollow(o)
  64. cardm[id] = card
  65. for _, item := range card.Items {
  66. switch item.Goto {
  67. case model.GotoMid:
  68. if item.ID != 0 {
  69. upIDs = append(upIDs, item.ID)
  70. }
  71. case model.GotoTag:
  72. if item.ID != 0 {
  73. tids = append(tids, item.ID)
  74. }
  75. }
  76. }
  77. }
  78. }
  79. return
  80. }
  81. func (s *Service) channelRcmdCard(c context.Context, ids ...int64) (cardm map[int64]*operate.Card, aids, tids []int64) {
  82. if len(ids) == 0 {
  83. return
  84. }
  85. cardm = make(map[int64]*operate.Card, len(ids))
  86. for _, id := range ids {
  87. if o, ok := s.upCardCache[id]; ok {
  88. card := &operate.Card{}
  89. card.FromFollow(o)
  90. cardm[id] = card
  91. switch card.Goto {
  92. case model.GotoAv:
  93. if card.ID != 0 {
  94. aids = append(aids, card.ID)
  95. }
  96. if card.Tid != 0 {
  97. tids = append(tids, card.Tid)
  98. }
  99. }
  100. }
  101. }
  102. return
  103. }
  104. func (s *Service) liveUpRcmdCard(c context.Context, ids ...int64) (cardm map[int64][]*live.Card, upIDs []int64) {
  105. if len(ids) == 0 {
  106. return
  107. }
  108. cardm = make(map[int64][]*live.Card, len(ids))
  109. for _, id := range ids {
  110. if card, ok := s.liveCardCache[id]; ok {
  111. cardm[id] = card
  112. for _, c := range card {
  113. if c.UID != 0 {
  114. upIDs = append(upIDs, c.UID)
  115. }
  116. }
  117. }
  118. }
  119. return
  120. }
  121. func (s *Service) specialCard(c context.Context, ids ...int64) (cardm map[int64]*operate.Card) {
  122. if len(ids) == 0 {
  123. return
  124. }
  125. cardm = make(map[int64]*operate.Card, len(ids))
  126. for _, id := range ids {
  127. if o, ok := s.specialCardCache[id]; ok {
  128. card := &operate.Card{}
  129. card.FromSpecial(o)
  130. cardm[id] = card
  131. }
  132. }
  133. return
  134. }
  135. func (s *Service) topstickCard(c context.Context, ids ...int64) (cardm map[int64]*operate.Card) {
  136. if len(ids) == 0 {
  137. return
  138. }
  139. cardm = make(map[int64]*operate.Card, len(ids))
  140. for _, id := range ids {
  141. if o, ok := s.specialCardCache[id]; ok {
  142. card := &operate.Card{}
  143. card.FromTopstick(o)
  144. cardm[id] = card
  145. }
  146. }
  147. return
  148. }
  149. func (s *Service) cardSetChange(c context.Context, ids ...int64) (cardm map[int64]*operate.Card, seasonIDs []int32) {
  150. if len(ids) == 0 {
  151. return
  152. }
  153. cardm = make(map[int64]*operate.Card, len(ids))
  154. for _, id := range ids {
  155. if cs, ok := s.cardSetCache[id]; ok {
  156. card := &operate.Card{}
  157. card.FromCardSet(cs)
  158. cardm[id] = card
  159. for _, item := range card.Items {
  160. switch cs.Type {
  161. case "pgcs_rcmd":
  162. seasonIDs = append(seasonIDs, int32(item.ID))
  163. }
  164. }
  165. }
  166. }
  167. return
  168. }