live_user.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. package v2
  2. import (
  3. "context"
  4. "fmt"
  5. v2pb "go-common/app/interface/live/app-interface/api/http/v2"
  6. liveUserDao "go-common/app/interface/live/app-interface/dao/live_user"
  7. liveUserV1 "go-common/app/service/live/live_user/api/liverpc/v1"
  8. "go-common/library/log"
  9. "go-common/library/net/metadata"
  10. )
  11. const (
  12. _mmtagType = 12
  13. _mseaType = 14
  14. )
  15. // GetIndexV2TagList ...
  16. // 获取APP首页 - 我的个人标签列表
  17. func (s *IndexService) GetIndexV2TagList(ctx context.Context, req *liveUserV1.UserSettingGetTagReq) (ret []*v2pb.MMyTag, err error) {
  18. ret = []*v2pb.MMyTag{}
  19. ExtraInfo := &v2pb.MyTagExtra{
  20. Offline: []*v2pb.OfflineTag{},
  21. }
  22. List := make([]*v2pb.MyTagItem, 0)
  23. res := &v2pb.MMyTag{}
  24. d := &liveUserDao.Dao{}
  25. moduleList := s.GetAllModuleInfoMapFromCache(ctx)
  26. module, ok := moduleList[_mmtagType]
  27. if false == ok || 0 == len(module) {
  28. log.Error("[GetUserTagList]AllMinfoMap is empty error:%+v, %+v", err, moduleList)
  29. return
  30. }
  31. for _, v := range module {
  32. if v.Type == _mmtagType {
  33. var data *liveUserV1.UserSettingGetTagResp_Data
  34. data, err = d.GetUserTagList(ctx, req)
  35. if err != nil {
  36. log.Error("[GetUserTagList]live_user.v1.getTag rpc error:%+v, %+v", err, data)
  37. return
  38. }
  39. ExtraInfo.IsGray = data.IsGray
  40. for _, offlineInfo := range data.Offline {
  41. ExtraInfo.Offline = append(ExtraInfo.Offline, &v2pb.OfflineTag{Id: int64(offlineInfo.Id), AreaV2Name: offlineInfo.Name})
  42. }
  43. for _, tagInfo := range data.Tags {
  44. link := fmt.Sprintf("http://live.bilibili.com/app/area?parent_area_id=%d&parent_area_name=%s&area_id=%d&area_name=%s", tagInfo.ParentId, tagInfo.ParentName, tagInfo.Id, tagInfo.Name)
  45. List = append(List, &v2pb.MyTagItem{AreaV2Id: int64(tagInfo.Id), AreaV2Name: tagInfo.Name, AreaV2ParentId: int64(tagInfo.ParentId), AreaV2ParentName: tagInfo.ParentName, Link: link, Pic: tagInfo.Pic, IsAdvice: int64(tagInfo.IsAdvice)})
  46. if len(List) >= 4 {
  47. break
  48. }
  49. }
  50. List = append(List, &v2pb.MyTagItem{AreaV2Id: 0, AreaV2Name: "全部标签", AreaV2ParentId: 0, AreaV2ParentName: "", Pic: "http://i0.hdslb.com/bfs/vc/ff03528785fc8c91491d79e440398484811d6d87.png", Link: "http://live.bilibili.com/app/mytag/", IsAdvice: 1})
  51. res.ExtraInfo = ExtraInfo
  52. res.List = List
  53. res.ModuleInfo = v
  54. }
  55. break
  56. }
  57. ret = append(ret, res)
  58. return
  59. }
  60. // GetIndexV2SeaPatrol ...
  61. // 获取APP首页 - 我的大航海提示信息
  62. func (s *IndexService) GetIndexV2SeaPatrol(ctx context.Context, req *liveUserV1.NoteGetReq) (ret []*v2pb.MSeaPatrol, err error) {
  63. ret = []*v2pb.MSeaPatrol{}
  64. _, isUIDSet := metadata.Value(ctx, metadata.Mid).(int64)
  65. if !isUIDSet {
  66. return
  67. }
  68. ExtraInfo := &v2pb.PicItem{}
  69. res := &v2pb.MSeaPatrol{}
  70. d := &liveUserDao.Dao{}
  71. moduleList := s.GetAllModuleInfoMapFromCache(ctx)
  72. module, ok := moduleList[_mseaType]
  73. if false == ok || 0 == len(module) {
  74. log.Error("[GetIndexV2SeaPatrol]AllMinfoMap is empty error:%+v, %+v", err, moduleList)
  75. return
  76. }
  77. for _, v := range module {
  78. if v.Type == _mseaType {
  79. var data *liveUserV1.NoteGetResp_Data
  80. data, err = d.GetDaHangHai(ctx, req)
  81. if err != nil {
  82. log.Error("[GetIndexV2SeaPatrol]live_user.v1.getNoteSea rpc error:%+v, %+v", err, data)
  83. return
  84. }
  85. if data.Title == "" || data.Link == "" { // 返回信息为空
  86. return
  87. }
  88. ExtraInfo.Title = data.Title
  89. ExtraInfo.Pic = data.Logo
  90. ExtraInfo.Link = data.Link
  91. ExtraInfo.Content = data.Content
  92. ExtraInfo.Id = 0
  93. res.ExtraInfo = ExtraInfo
  94. res.ModuleInfo = v
  95. }
  96. break
  97. }
  98. ret = append(ret, res)
  99. return
  100. }