rpc.go 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package dao
  2. import (
  3. "context"
  4. accmdl "go-common/app/service/main/account/model"
  5. spymdl "go-common/app/service/main/spy/model"
  6. "go-common/library/log"
  7. "go-common/library/net/metadata"
  8. )
  9. // UserScore get userscore by id , will init score if score not exist.
  10. func (d *Dao) UserScore(c context.Context, mid int64) (userScore *spymdl.UserScore, err error) {
  11. var argUserScore = &spymdl.ArgUserScore{
  12. Mid: mid,
  13. IP: metadata.String(c, metadata.RemoteIP),
  14. }
  15. if userScore, err = d.spyRPC.UserScore(c, argUserScore); err != nil {
  16. log.Error("dao.spyRPC.UserScore(%v) error(%v)", argUserScore, err)
  17. return
  18. }
  19. return
  20. }
  21. // AccInfo get account info by mid
  22. func (d *Dao) AccInfo(c context.Context, mid int64) (ai *accmdl.Info, err error) {
  23. arg := &accmdl.ArgMid{Mid: mid}
  24. if ai, err = d.accRPC.Info3(c, arg); err != nil || ai == nil {
  25. log.Error("s.accRPC.Info(%d) error(%v)", mid, err)
  26. }
  27. return
  28. }
  29. // ResetBase reset user base score.
  30. func (d *Dao) ResetBase(c context.Context, mid int64, operator string) (err error) {
  31. arg := &spymdl.ArgReset{
  32. Mid: mid,
  33. BaseScore: true,
  34. Operator: operator,
  35. }
  36. if err = d.spyRPC.UpdateBaseScore(c, arg); err != nil {
  37. log.Error("s.spyRPC.UpdateBaseScore(%v) error(%v)", arg, err)
  38. return
  39. }
  40. return
  41. }
  42. // RefreshBase reset user base score.
  43. func (d *Dao) RefreshBase(c context.Context, mid int64, operator string) (err error) {
  44. arg := &spymdl.ArgReset{
  45. Mid: mid,
  46. BaseScore: true,
  47. Operator: operator,
  48. }
  49. if err = d.spyRPC.RefreshBaseScore(c, arg); err != nil {
  50. log.Error("s.spyRPC.RefreshBaseScore(%v) error(%v)", arg, err)
  51. return
  52. }
  53. return
  54. }
  55. // ResetEvent reset user event score.
  56. func (d *Dao) ResetEvent(c context.Context, mid int64, operator string) (err error) {
  57. arg := &spymdl.ArgReset{
  58. Mid: mid,
  59. EventScore: true,
  60. Operator: operator,
  61. }
  62. if err = d.spyRPC.UpdateEventScore(c, arg); err != nil {
  63. log.Error("s.spyRPC.UpdateEventScore(%v) error(%v)", arg, err)
  64. return
  65. }
  66. return
  67. }
  68. // ClearCount clear count.
  69. func (d *Dao) ClearCount(c context.Context, mid int64, operator string) (err error) {
  70. arg := &spymdl.ArgReset{
  71. Mid: mid,
  72. ReLiveTime: true,
  73. Operator: operator,
  74. }
  75. if err = d.spyRPC.ClearReliveTimes(c, arg); err != nil {
  76. log.Error("d.spyRPC.ClearReliveTimes(%v) error(%v)", arg, err)
  77. return
  78. }
  79. return
  80. }