search.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package feed
  2. import (
  3. "context"
  4. "strconv"
  5. "go-common/app/interface/main/app-card/model"
  6. "go-common/app/interface/main/app-card/model/card/operate"
  7. )
  8. func (s *Service) SearchFollow(c context.Context, platform, mobiApp, device, buvid string, build int, mid int64) (follow *operate.Follow, err error) {
  9. const _title = "人气UP主推荐"
  10. ups, trackID, err := s.search.Follow(c, platform, mobiApp, device, buvid, build, mid)
  11. if err != nil {
  12. return
  13. }
  14. items := make([]*operate.Follow, 0, len(ups))
  15. for _, up := range ups {
  16. if up.Mid != 0 {
  17. item := &operate.Follow{Pid: up.Mid, Goto: model.GotoMid}
  18. items = append(items, item)
  19. }
  20. }
  21. if len(items) < 3 {
  22. return
  23. }
  24. id, _ := strconv.ParseInt(trackID, 10, 64)
  25. if id < 1 {
  26. return
  27. }
  28. follow = &operate.Follow{ID: id, Items: items, Title: _title, Type: "upper"}
  29. return
  30. }
  31. func (s *Service) SearchFollow2(c context.Context, platform, mobiApp, device, buvid string, build int, mid int64) (follow *operate.Card, err error) {
  32. const _title = "人气UP主推荐"
  33. ups, trackID, err := s.search.Follow(c, platform, mobiApp, device, buvid, build, mid)
  34. if err != nil {
  35. return
  36. }
  37. items := make([]*operate.Card, 0, len(ups))
  38. for _, up := range ups {
  39. if up.Mid != 0 {
  40. item := &operate.Card{ID: up.Mid, Goto: model.GotoMid, Param: strconv.FormatInt(up.Mid, 10), URI: strconv.FormatInt(up.Mid, 10), Desc: up.RecReason}
  41. items = append(items, item)
  42. }
  43. }
  44. if len(items) < 3 {
  45. return
  46. }
  47. id, _ := strconv.ParseInt(trackID, 10, 64)
  48. if id < 1 {
  49. return
  50. }
  51. follow = &operate.Card{ID: id, Param: trackID, Items: items, Title: _title, CardGoto: model.CardGotoSearchSubscribe}
  52. return
  53. }