rpc.go 1.3 KB

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