medal.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package member
  2. import (
  3. "context"
  4. "go-common/app/service/main/usersuit/model"
  5. "go-common/library/log"
  6. "go-common/library/net/metadata"
  7. )
  8. // MedalHomeInfo return user mdeal home info.
  9. func (s *Service) MedalHomeInfo(c context.Context, mid int64) (res []*model.MedalHomeInfo, err error) {
  10. var arg = &model.ArgMid{Mid: mid}
  11. res, err = s.usRPC.MedalHomeInfo(c, arg)
  12. if err != nil {
  13. log.Error("s.medalRPC.MedalHomeInfo(%d) error (%v)", mid, err)
  14. return
  15. }
  16. return
  17. }
  18. // MedalUserInfo return medal user info.
  19. func (s *Service) MedalUserInfo(c context.Context, mid int64) (res *model.MedalUserInfo, err error) {
  20. ip := metadata.String(c, metadata.RemoteIP)
  21. var arg = &model.ArgMedalUserInfo{Mid: mid, IP: ip}
  22. res, err = s.usRPC.MedalUserInfo(c, arg)
  23. if err != nil {
  24. log.Error("s.medalRPC.MedalUserInfo(%d) error (%v)", mid, err)
  25. return
  26. }
  27. return
  28. }
  29. // MedalInstall install or uninstall medal.
  30. func (s *Service) MedalInstall(c context.Context, mid, nid int64, isActivated int8) (err error) {
  31. var arg = &model.ArgMedalInstall{Mid: mid, Nid: nid, IsActivated: isActivated}
  32. err = s.usRPC.MedalInstall(c, arg)
  33. if err != nil {
  34. log.Error("s.medalRPC.MedalInstall(mid:%d nid:%d isActivated:%d) error (%v)", mid, nid, isActivated, err)
  35. return
  36. }
  37. return
  38. }
  39. // MedalPopup return medal popup.
  40. func (s *Service) MedalPopup(c context.Context, mid int64) (res *model.MedalPopup, err error) {
  41. var arg = &model.ArgMid{Mid: mid}
  42. res, err = s.usRPC.MedalPopup(c, arg)
  43. if err != nil {
  44. log.Error("s.medalRPC.MedalPopup(mid:%d) error (%v)", mid, err)
  45. return
  46. }
  47. return
  48. }
  49. // MedalMyInfo return medal my info.
  50. func (s *Service) MedalMyInfo(c context.Context, mid int64) (res []*model.MedalMyInfos, err error) {
  51. var arg = &model.ArgMid{Mid: mid}
  52. res, err = s.usRPC.MedalMyInfo(c, arg)
  53. if err != nil {
  54. log.Error("s.medalRPC.MedalMyInfo(mid:%d) error (%v)", mid, err)
  55. return
  56. }
  57. return
  58. }
  59. // MedalAllInfo return medal all info.
  60. func (s *Service) MedalAllInfo(c context.Context, mid int64) (res *model.MedalAllInfos, err error) {
  61. var arg = &model.ArgMid{Mid: mid}
  62. res, err = s.usRPC.MedalAllInfo(c, arg)
  63. if err != nil {
  64. log.Error("s.medalRPC.MedalAllInfo(mid:%d) error (%v)", mid, err)
  65. return
  66. }
  67. return
  68. }