account3.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. package client
  2. import (
  3. "context"
  4. v1 "go-common/app/service/main/account/api"
  5. "go-common/app/service/main/account/model"
  6. "go-common/library/net/rpc"
  7. )
  8. const (
  9. _info3 = "RPC.Info3"
  10. _card3 = "RPC.Card3"
  11. _infos3 = "RPC.Infos3"
  12. _infosByName3 = "RPC.InfosByName3"
  13. _cards3 = "RPC.Cards3"
  14. _profile3 = "RPC.Profile3"
  15. _profileStat3 = "RPC.ProfileWithStat3"
  16. _addExp3 = "RPC.AddExp3"
  17. _addMoral3 = "RPC.AddMoral3"
  18. _relation3 = "RPC.Relation3"
  19. _relations3 = "RPC.Relations3"
  20. _attentions3 = "RPC.Attentions3"
  21. _blacks3 = "RPC.Blacks3"
  22. _richRelations3 = "RPC.RichRelations3"
  23. )
  24. const (
  25. _appid = "account.service"
  26. )
  27. var (
  28. _noArg = &struct{}{}
  29. )
  30. // Service3 for server client3
  31. type Service3 struct {
  32. client *rpc.Client2
  33. }
  34. // New3 for new struct Service2 obj
  35. func New3(c *rpc.ClientConfig) (s *Service3) {
  36. s = &Service3{}
  37. s.client = rpc.NewDiscoveryCli(_appid, c)
  38. return
  39. }
  40. // Info3 receive ArgMid contains mid and real ip, then init user info.
  41. func (s *Service3) Info3(c context.Context, arg *model.ArgMid) (res *v1.Info, err error) {
  42. res = new(v1.Info)
  43. err = s.client.Call(c, _info3, arg, res)
  44. return
  45. }
  46. // Card3 receive ArgMid contains mid and real ip, then init user card.
  47. func (s *Service3) Card3(c context.Context, arg *model.ArgMid) (res *v1.Card, err error) {
  48. res = new(v1.Card)
  49. err = s.client.Call(c, _card3, arg, res)
  50. return
  51. }
  52. // Infos3 receive ArgMids contains mid and real ip, then init user info.
  53. func (s *Service3) Infos3(c context.Context, arg *model.ArgMids) (res map[int64]*v1.Info, err error) {
  54. err = s.client.Call(c, _infos3, arg, &res)
  55. return
  56. }
  57. // InfosByName3 receive ArgMids contains mid and real ip, then init user info.
  58. func (s *Service3) InfosByName3(c context.Context, arg *model.ArgNames) (res map[int64]*v1.Info, err error) {
  59. err = s.client.Call(c, _infosByName3, arg, &res)
  60. return
  61. }
  62. // Cards3 receive ArgMids contains mid and real ip, then init user card.
  63. func (s *Service3) Cards3(c context.Context, arg *model.ArgMids) (res map[int64]*v1.Card, err error) {
  64. err = s.client.Call(c, _cards3, arg, &res)
  65. return
  66. }
  67. // Profile3 get user profile.
  68. func (s *Service3) Profile3(c context.Context, arg *model.ArgMid) (res *v1.Profile, err error) {
  69. res = new(v1.Profile)
  70. err = s.client.Call(c, _profile3, arg, res)
  71. return
  72. }
  73. // ProfileWithStat3 get user profile.
  74. func (s *Service3) ProfileWithStat3(c context.Context, arg *model.ArgMid) (res *model.ProfileStat, err error) {
  75. res = new(model.ProfileStat)
  76. err = s.client.Call(c, _profileStat3, arg, res)
  77. return
  78. }
  79. // AddExp3 receive ArgExp contains mid, money and reason, then add exp for user.
  80. func (s *Service3) AddExp3(c context.Context, arg *model.ArgExp) (err error) {
  81. err = s.client.Call(c, _addExp3, arg, _noArg)
  82. return
  83. }
  84. // AddMoral3 receive ArgMoral contains mid, moral, oper, reason and remark, then add moral for user.
  85. func (s *Service3) AddMoral3(c context.Context, arg *model.ArgMoral) (err error) {
  86. err = s.client.Call(c, _addMoral3, arg, _noArg)
  87. return
  88. }
  89. // Relation3 get user friend relation.
  90. func (s *Service3) Relation3(c context.Context, arg *model.ArgRelation) (res *model.Relation, err error) {
  91. res = new(model.Relation)
  92. err = s.client.Call(c, _relation3, arg, res)
  93. return
  94. }
  95. // Relations3 batch get user friend relation.
  96. func (s *Service3) Relations3(c context.Context, arg *model.ArgRelations) (res map[int64]*model.Relation, err error) {
  97. err = s.client.Call(c, _relations3, arg, &res)
  98. return
  99. }
  100. // Attentions3 get user attentions ,include followings and whispers.
  101. func (s *Service3) Attentions3(c context.Context, arg *model.ArgMid) (res []int64, err error) {
  102. err = s.client.Call(c, _attentions3, arg, &res)
  103. return
  104. }
  105. // Blacks3 get user black list.
  106. func (s *Service3) Blacks3(c context.Context, arg *model.ArgMid) (res map[int64]struct{}, err error) {
  107. err = s.client.Call(c, _blacks3, arg, &res)
  108. return
  109. }
  110. // RichRelations3 get relation between owner and mids.
  111. func (s *Service3) RichRelations3(c context.Context, arg *model.ArgRichRelation) (res map[int64]int, err error) {
  112. err = s.client.Call(c, _richRelations3, arg, &res)
  113. return
  114. }