activity_card.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package v2
  2. import (
  3. "context"
  4. v2pb "go-common/app/interface/live/app-interface/api/http/v2"
  5. )
  6. // getActivityCard 活动模块
  7. func (s *IndexService) getActivityCard(ctx context.Context) (resp []*v2pb.MActivityCard) {
  8. resp = []*v2pb.MActivityCard{}
  9. ids := s.getIdsFromModuleMap(ctx, []int64{_activityType})
  10. if len(ids) <= 0 {
  11. return
  12. }
  13. err, activityCardMap := s.roomDao.GetActivityCard(ctx, ids, "GetAllList")
  14. if err != nil {
  15. return
  16. }
  17. listMap := make(map[int64][]*v2pb.ActivityCardItem)
  18. for i, ac := range activityCardMap {
  19. respAc := &v2pb.ActivityCardItem{Room: []*v2pb.RoomCardItem{}, Av: []*v2pb.AvCardItem{}}
  20. respAc.Card = &v2pb.BannerCardItem{
  21. Aid: ac.Card.Aid,
  22. Pic: ac.Card.Pic,
  23. Title: ac.Card.Title,
  24. Text: ac.Card.Text,
  25. PicLink: ac.Card.PicLink,
  26. GoLink: ac.Card.GoLink,
  27. ButtonText: ac.Card.ButtonText,
  28. Status: ac.Card.Status,
  29. Sort: ac.Card.Sort,
  30. }
  31. if len(ac.Room) > 0 {
  32. for _, room := range ac.Room {
  33. roomCard := &v2pb.RoomCardItem{
  34. IsLive: room.IsLive,
  35. RoomId: room.Roomid,
  36. Title: room.Title,
  37. UName: room.Uname,
  38. Online: room.Online,
  39. Cover: room.Cover,
  40. AreaV2ParentId: room.AreaV2ParentId,
  41. AreaV2Id: room.AreaV2Id,
  42. Sort: room.Sort,
  43. }
  44. respAc.Room = append(respAc.Room, roomCard)
  45. }
  46. }
  47. if len(ac.Av) > 0 {
  48. for _, av := range ac.Av {
  49. avCard := &v2pb.AvCardItem{
  50. Avid: av.Avid,
  51. Title: av.Title,
  52. ViewCount: av.ViewCount,
  53. DanMaKu: av.Danmaku,
  54. Duration: av.Duration,
  55. Cover: av.Cover,
  56. Sort: av.Sort,
  57. }
  58. respAc.Av = append(respAc.Av, avCard)
  59. }
  60. }
  61. listMap[i] = append(listMap[i], respAc)
  62. }
  63. moduleInfoMap := s.getAllModuleInfoMap(ctx)
  64. for _, m := range moduleInfoMap[_activityType] {
  65. if l, ok := listMap[m.Id]; ok {
  66. resp = append(resp, &v2pb.MActivityCard{
  67. ModuleInfo: m,
  68. List: l,
  69. })
  70. }
  71. }
  72. return
  73. }