userInfo.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package account
  2. import (
  3. "context"
  4. "github.com/pkg/errors"
  5. "go-common/app/service/main/account/api"
  6. accountM "go-common/app/service/main/account/model"
  7. actmdl "go-common/app/service/main/account/model"
  8. "go-common/library/ecode"
  9. "go-common/library/log"
  10. )
  11. // GetUserInfoData ...
  12. // 调用account grpc接口cards获取用户信息
  13. func (d *Dao) GetUserInfoData(c context.Context, UIDs []int64) (userResult map[int64]*accountM.Card, err error) {
  14. userResult = make(map[int64]*accountM.Card)
  15. lens := len(UIDs)
  16. if lens <= 0 {
  17. return
  18. }
  19. ret, err := d.accountRPC.Cards3(c, &actmdl.ArgMids{Mids: UIDs})
  20. if err != nil {
  21. err = errors.WithMessage(ecode.AccountGRPCError, "GET SEA PATROL FAIL")
  22. log.Error("Call main.Account.Cards Error.Infos(%+v) error(%+v)", UIDs, err)
  23. }
  24. // 整理数据
  25. for _, item := range ret {
  26. if item != nil {
  27. userResult[item.Mid] = item
  28. }
  29. }
  30. return
  31. }
  32. func (d *Dao) GetUserInfos(c context.Context, uids []int64) (userResult map[int64]*api.Info, err error) {
  33. userResult = make(map[int64]*api.Info)
  34. if len(uids) <= 0 {
  35. return
  36. }
  37. ret, err := d.accountRPC.Infos3(c, &actmdl.ArgMids{Mids: uids})
  38. if err != nil {
  39. err = errors.WithMessage(ecode.AccountGRPCError, "GET USER INFO FAIL")
  40. log.Error("Call main.Account.Info3 Error.Infos(%+v) error(%+v)", uids, err)
  41. }
  42. userResult = ret
  43. return
  44. }