rpc3.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package server
  2. import (
  3. v1 "go-common/app/service/main/account/api"
  4. "go-common/app/service/main/account/model"
  5. "go-common/library/net/rpc/context"
  6. )
  7. // Info3 receive ArgMid contains mid and real ip, then init user info.
  8. func (r *RPC) Info3(c context.Context, arg *model.ArgMid, res *v1.Info) (err error) {
  9. var info *v1.Info
  10. if info, err = r.s.Info(c, arg.Mid); err == nil && info != nil {
  11. *res = *info
  12. }
  13. return
  14. }
  15. // Infos3 receive ArgMids contains mids and real ip, then multi init user info.
  16. func (r *RPC) Infos3(c context.Context, a *model.ArgMids, res *map[int64]*v1.Info) (err error) {
  17. *res, err = r.s.Infos(c, a.Mids)
  18. return
  19. }
  20. // InfosByName3 receive ArgMids contains mids and real ip, then multi init user info.
  21. func (r *RPC) InfosByName3(c context.Context, a *model.ArgNames, res *map[int64]*v1.Info) (err error) {
  22. *res, err = r.s.InfosByName(c, a.Names)
  23. return
  24. }
  25. // Card3 receive ArgMid contains mid and real ip, then init user card.
  26. func (r *RPC) Card3(c context.Context, arg *model.ArgMid, res *v1.Card) (err error) {
  27. var card *v1.Card
  28. if card, err = r.s.Card(c, arg.Mid); err == nil && res != nil {
  29. *res = *card
  30. }
  31. return
  32. }
  33. // Cards3 receive ArgMids contains mids and real ip, then multi init user card.
  34. func (r *RPC) Cards3(c context.Context, a *model.ArgMids, res *map[int64]*v1.Card) (err error) {
  35. *res, err = r.s.Cards(c, a.Mids)
  36. return
  37. }
  38. // Profile3 get user audit info.
  39. func (r *RPC) Profile3(c context.Context, arg *model.ArgMid, res *v1.Profile) (err error) {
  40. var p *v1.Profile
  41. if p, err = r.s.Profile(c, arg.Mid); err == nil && p != nil {
  42. *res = *p
  43. }
  44. return
  45. }
  46. // ProfileWithStat3 get user audit info.
  47. func (r *RPC) ProfileWithStat3(c context.Context, arg *model.ArgMid, res *model.ProfileStat) (err error) {
  48. var p *model.ProfileStat
  49. if p, err = r.s.ProfileWithStat(c, arg.Mid); err == nil && p != nil {
  50. *res = *p
  51. }
  52. return
  53. }
  54. // AddExp3 add exp for user.
  55. func (r *RPC) AddExp3(c context.Context, a *model.ArgExp, res *struct{}) (err error) {
  56. err = r.s.AddExp(c, a.Mid, a.Exp, a.Operater, a.Operate, a.Reason)
  57. return
  58. }
  59. // AddMoral3 receive ArgMoral contains mid, moral, oper, reason and remark, then add moral for user.
  60. func (r *RPC) AddMoral3(c context.Context, a *model.ArgMoral, res *struct{}) (err error) {
  61. err = r.s.AddMoral(c, a.Mid, a.Moral, a.Oper, a.Reason, a.Remark)
  62. return
  63. }
  64. // Relation3 get friend relation.
  65. func (r *RPC) Relation3(c context.Context, a *model.ArgRelation, res *model.Relation) (err error) {
  66. var rl *model.Relation
  67. if rl, err = r.s.Relation(c, a.Mid, a.Owner); err == nil && rl != nil {
  68. *res = *rl
  69. }
  70. return
  71. }
  72. // Attentions3 get attentions list ,including following and whisper.
  73. func (r *RPC) Attentions3(c context.Context, a *model.ArgMid, res *[]int64) (err error) {
  74. *res, err = r.s.Attentions(c, a.Mid)
  75. return
  76. }
  77. // Blacks3 get user black list.
  78. func (r *RPC) Blacks3(c context.Context, a *model.ArgMid, res *map[int64]struct{}) (err error) {
  79. *res, err = r.s.Blacks(c, a.Mid)
  80. return
  81. }
  82. // Relations3 get friend relations.
  83. func (r *RPC) Relations3(c context.Context, a *model.ArgRelations, res *map[int64]*model.Relation) (err error) {
  84. *res, err = r.s.Relations(c, a.Mid, a.Owners)
  85. return
  86. }
  87. // RichRelations3 get friend relations.
  88. func (r *RPC) RichRelations3(c context.Context, a *model.ArgRichRelation, res *map[int64]int) (err error) {
  89. *res, err = r.s.RichRelations2(c, a.Owner, a.Mids)
  90. return
  91. }