rpc.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package block
  2. import (
  3. "context"
  4. account "go-common/app/service/main/account/api"
  5. mdlfigure "go-common/app/service/main/figure/model"
  6. mdlspy "go-common/app/service/main/spy/model"
  7. "go-common/library/net/metadata"
  8. "github.com/pkg/errors"
  9. )
  10. // SpyScore .
  11. func (s *Service) SpyScore(c context.Context, mid int64) (score int8, err error) {
  12. var (
  13. arg = &mdlspy.ArgUserScore{
  14. Mid: mid,
  15. }
  16. res *mdlspy.UserScore
  17. )
  18. if res, err = s.spyRPC.UserScore(c, arg); err != nil {
  19. err = errors.WithStack(err)
  20. return
  21. }
  22. if res == nil {
  23. return
  24. }
  25. score = res.Score
  26. return
  27. }
  28. // FigureRank .
  29. func (s *Service) FigureRank(c context.Context, mid int64) (rank int8, err error) {
  30. var (
  31. arg = &mdlfigure.ArgUserFigure{
  32. Mid: mid,
  33. }
  34. res *mdlfigure.FigureWithRank
  35. )
  36. if res, err = s.figureRPC.UserFigure(c, arg); err != nil {
  37. err = errors.WithStack(err)
  38. return
  39. }
  40. if res == nil {
  41. rank = 100
  42. return
  43. }
  44. rank = res.Percentage
  45. return
  46. }
  47. // AccountInfo .
  48. func (s *Service) AccountInfo(c context.Context, mid int64) (nickname string, tel int32, level int32, regTime int64, err error) {
  49. var (
  50. arg = &account.MidReq{
  51. Mid: mid,
  52. RealIp: metadata.String(c, metadata.RemoteIP),
  53. }
  54. profileReply *account.ProfileReply
  55. )
  56. if profileReply, err = s.accountClient.Profile3(c, arg); err != nil {
  57. err = errors.WithStack(err)
  58. return
  59. }
  60. res := profileReply.Profile
  61. nickname = res.Name
  62. tel = res.TelStatus
  63. level = res.Level
  64. regTime = int64(res.JoinTime)
  65. return
  66. }