rpc.go 752 B

123456789101112131415161718192021222324252627282930313233343536
  1. package service
  2. import (
  3. "context"
  4. favmdl "go-common/app/service/main/favorite/model"
  5. "go-common/library/log"
  6. "go-common/library/net/metadata"
  7. )
  8. // favoriteds return aids is favs.
  9. func (s *Service) favoriteds(c context.Context, mid int64, aids []int64) (res map[int64]bool) {
  10. var n = 50
  11. res = make(map[int64]bool, len(aids))
  12. for len(aids) > 0 {
  13. if n > len(aids) {
  14. n = len(aids)
  15. }
  16. arg := &favmdl.ArgIsFavs{
  17. Type: favmdl.TypeVideo,
  18. Mid: mid,
  19. Oids: aids[:n],
  20. RealIP: metadata.String(c, metadata.RemoteIP),
  21. }
  22. favMap, err := s.favRPC.IsFavs(c, arg)
  23. if err != nil {
  24. log.Error("s.favRPC.IsFavs(%v) error(%v)", arg, err)
  25. return
  26. }
  27. aids = aids[n:]
  28. for k, v := range favMap {
  29. res[k] = v
  30. }
  31. }
  32. return
  33. }