spy.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. package spy
  2. import (
  3. "context"
  4. "go-common/app/service/main/spy/model"
  5. "go-common/library/net/rpc"
  6. )
  7. const (
  8. _addEvent = "RPC.HandleEvent"
  9. _userScore = "RPC.UserScore"
  10. _reBuildPortrait = "RPC.ReBuildPortrait"
  11. //_resetManually = "RPC.ResetManually"
  12. _updateBaseScore = "RPC.UpdateBaseScore"
  13. _refreshBaseScore = "RPC.RefreshBaseScore"
  14. _updateEventScore = "RPC.UpdateEventScore"
  15. _userInfo = "RPC.UserInfo"
  16. _clearReliveTimes = "RPC.ClearReliveTimes"
  17. _statByID = "RPC.StatByID"
  18. )
  19. const (
  20. _appid = "account.service.spy"
  21. )
  22. var (
  23. _noRes = &struct{}{}
  24. )
  25. // Service struct info.
  26. type Service struct {
  27. client *rpc.Client2
  28. }
  29. // New create instance of service and return.
  30. func New(c *rpc.ClientConfig) (s *Service) {
  31. s = &Service{}
  32. s.client = rpc.NewDiscoveryCli(_appid, c)
  33. return
  34. }
  35. // HandleEvent add spy event to user.
  36. func (s *Service) HandleEvent(c context.Context, arg *model.ArgHandleEvent) (err error) {
  37. err = s.client.Call(c, _addEvent, arg, _noRes)
  38. return
  39. }
  40. // UserScore archive get user spy score.
  41. func (s *Service) UserScore(c context.Context, arg *model.ArgUserScore) (res *model.UserScore, err error) {
  42. res = &model.UserScore{}
  43. err = s.client.Call(c, _userScore, arg, res)
  44. return
  45. }
  46. // ReBuildPortrait rebuild user risk portrait by task.
  47. func (s *Service) ReBuildPortrait(c context.Context, arg *model.ArgReBuild) (err error) {
  48. err = s.client.Call(c, _reBuildPortrait, arg, _noRes)
  49. return
  50. }
  51. // UpdateBaseScore cli.
  52. func (s *Service) UpdateBaseScore(c context.Context, arg *model.ArgReset) (err error) {
  53. err = s.client.Call(c, _updateBaseScore, arg, _noRes)
  54. return
  55. }
  56. // RefreshBaseScore cli.
  57. func (s *Service) RefreshBaseScore(c context.Context, arg *model.ArgReset) (err error) {
  58. err = s.client.Call(c, _refreshBaseScore, arg, _noRes)
  59. return
  60. }
  61. // UpdateEventScore cli.
  62. func (s *Service) UpdateEventScore(c context.Context, arg *model.ArgReset) (err error) {
  63. err = s.client.Call(c, _updateEventScore, arg, _noRes)
  64. return
  65. }
  66. // UserInfo cli.
  67. func (s *Service) UserInfo(c context.Context, arg *model.ArgUser) (res *model.UserInfo, err error) {
  68. err = s.client.Call(c, _userInfo, arg, res)
  69. return
  70. }
  71. // ClearReliveTimes cli.
  72. func (s *Service) ClearReliveTimes(c context.Context, arg *model.ArgReset) (err error) {
  73. err = s.client.Call(c, _clearReliveTimes, arg, _noRes)
  74. return
  75. }
  76. // StatByID cli.
  77. func (s *Service) StatByID(c context.Context, arg *model.ArgStat) (stat []*model.Statistics, err error) {
  78. err = s.client.Call(c, _statByID, arg, &stat)
  79. return
  80. }