client.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. package client
  2. import (
  3. "context"
  4. "go-common/app/service/main/usersuit/model"
  5. "go-common/library/net/rpc"
  6. )
  7. const (
  8. _appid = "account.service.usersuit"
  9. )
  10. var (
  11. _noRes = &struct{}{}
  12. )
  13. // Service2 struct
  14. type Service2 struct {
  15. client *rpc.Client2
  16. }
  17. // New Service2 init
  18. func New(c *rpc.ClientConfig) (s *Service2) {
  19. s = &Service2{}
  20. s.client = rpc.NewDiscoveryCli(_appid, c)
  21. return
  22. }
  23. const (
  24. _buy = "RPC.Buy"
  25. _apply = "RPC.Apply"
  26. _stat = "RPC.Stat"
  27. _generate = "RPC.Generate"
  28. _list = "RPC.List"
  29. _equip = "RPC.Equip"
  30. _grantByMids = "RPC.GrantByMids"
  31. _groupPendantMid = "RPC.GroupPendantMid"
  32. )
  33. // Buy buy invite
  34. func (s *Service2) Buy(c context.Context, arg *model.ArgBuy) (res []*model.Invite, err error) {
  35. res = make([]*model.Invite, 0)
  36. err = s.client.Call(c, _buy, arg, &res)
  37. return
  38. }
  39. // Apply apply
  40. func (s *Service2) Apply(c context.Context, arg *model.ArgApply) (err error) {
  41. err = s.client.Call(c, _apply, arg, _noRes)
  42. return
  43. }
  44. // Stat stat
  45. func (s *Service2) Stat(c context.Context, arg *model.ArgStat) (res *model.InviteStat, err error) {
  46. res = new(model.InviteStat)
  47. err = s.client.Call(c, _stat, arg, res)
  48. return
  49. }
  50. // Generate generator
  51. func (s *Service2) Generate(c context.Context, arg *model.ArgGenerate) (res []*model.Invite, err error) {
  52. res = make([]*model.Invite, 0)
  53. err = s.client.Call(c, _generate, arg, &res)
  54. return
  55. }
  56. // List list
  57. func (s *Service2) List(c context.Context, arg *model.ArgList) (res []*model.Invite, err error) {
  58. res = make([]*model.Invite, 0)
  59. err = s.client.Call(c, _list, arg, &res)
  60. return
  61. }
  62. // Equip pendant equip.
  63. func (s *Service2) Equip(c context.Context, arg *model.ArgEquip) (err error) {
  64. err = s.client.Call(c, _equip, arg, _noRes)
  65. return
  66. }
  67. // GrantByMids one pendant give to multiple users.
  68. func (s *Service2) GrantByMids(c context.Context, arg *model.ArgGrantByMids) (err error) {
  69. err = s.client.Call(c, _grantByMids, arg, _noRes)
  70. return
  71. }
  72. // GroupPendantMid get share group pendant by mid
  73. func (s *Service2) GroupPendantMid(c context.Context, arg *model.ArgGPMID) (res []*model.GroupPendantList, err error) {
  74. res = make([]*model.GroupPendantList, 0)
  75. err = s.client.Call(c, _groupPendantMid, arg, &res)
  76. return
  77. }