rpc.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package client
  2. import (
  3. "context"
  4. "go-common/app/service/main/point/model"
  5. "go-common/library/net/rpc"
  6. )
  7. const (
  8. _pointInfo = "RPC.PointInfo"
  9. _pointConsume = "RPC.ConsumePoint"
  10. _pointAdd = "RPC.PointAdd"
  11. _pointHistory = "RPC.PointHistory"
  12. _pointAddByBp = "RPC.PointAddByBp"
  13. )
  14. const (
  15. _appid = "account.service.point"
  16. )
  17. // Service is a question service.
  18. type Service struct {
  19. client *rpc.Client2
  20. }
  21. // New new rpc service.
  22. func New(c *rpc.ClientConfig) (s *Service) {
  23. s = &Service{}
  24. s.client = rpc.NewDiscoveryCli(_appid, c)
  25. return
  26. }
  27. // Ping rpc ping.
  28. func (s *Service) Ping(c context.Context, arg *struct{}) (res *int, err error) {
  29. err = s.client.Call(c, "RPC.Ping", arg, res)
  30. return
  31. }
  32. //PointInfo point info.
  33. func (s *Service) PointInfo(c context.Context, arg *model.ArgRPCMid) (res *model.PointInfo, err error) {
  34. res = new(model.PointInfo)
  35. err = s.client.Call(c, _pointInfo, arg, res)
  36. return
  37. }
  38. //ConsumePoint consume point.
  39. func (s *Service) ConsumePoint(c context.Context, arg *model.ArgPointConsume) (status int8, err error) {
  40. err = s.client.Call(c, _pointConsume, arg, &status)
  41. return
  42. }
  43. //AddPoint add point.
  44. func (s *Service) AddPoint(c context.Context, arg *model.ArgPoint) (status int8, err error) {
  45. err = s.client.Call(c, _pointAdd, arg, &status)
  46. return
  47. }
  48. // PointHistory point history.
  49. func (s *Service) PointHistory(c context.Context, arg *model.ArgRPCPointHistory) (res *model.PointHistoryResp, err error) {
  50. res = new(model.PointHistoryResp)
  51. err = s.client.Call(c, _pointHistory, arg, res)
  52. return
  53. }
  54. // PointAddByBp point add by bp.
  55. func (s *Service) PointAddByBp(c context.Context, arg *model.ArgPointAdd) (res *int64, err error) {
  56. err = s.client.Call(c, _pointAddByBp, arg, &res)
  57. return
  58. }