medal.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package server
  2. import (
  3. "go-common/app/service/main/usersuit/model"
  4. "go-common/library/net/rpc/context"
  5. )
  6. // MedalHomeInfo return user mdeal home info.
  7. func (r *RPC) MedalHomeInfo(c context.Context, arg *model.ArgMid, res *[]*model.MedalHomeInfo) (err error) {
  8. *res, err = r.s.MedalHomeInfo(c, arg.Mid)
  9. return
  10. }
  11. // MedalUserInfo return medal user info.
  12. func (r *RPC) MedalUserInfo(c context.Context, arg *model.ArgMedalUserInfo, res *model.MedalUserInfo) (err error) {
  13. var mui *model.MedalUserInfo
  14. if mui, err = r.s.MedalUserInfo(c, arg.Mid, arg.IP); err == nil && mui != nil {
  15. *res = *mui
  16. }
  17. return
  18. }
  19. // MedalInstall install or uninstall medal.
  20. func (r *RPC) MedalInstall(c context.Context, arg *model.ArgMedalInstall, res *struct{}) (err error) {
  21. err = r.s.MedalInstall(c, arg.Mid, arg.Nid, arg.IsActivated)
  22. return
  23. }
  24. // MedalPopup return medal popup.
  25. func (r *RPC) MedalPopup(c context.Context, arg *model.ArgMid, res *model.MedalPopup) (err error) {
  26. var mp *model.MedalPopup
  27. if mp, err = r.s.MedalPopup(c, arg.Mid); err == nil && mp != nil {
  28. *res = *mp
  29. }
  30. return
  31. }
  32. // MedalMyInfo return medal my info.
  33. func (r *RPC) MedalMyInfo(c context.Context, arg *model.ArgMid, res *[]*model.MedalMyInfos) (err error) {
  34. *res, err = r.s.MedalMyInfo(c, arg.Mid)
  35. return
  36. }
  37. // MedalAllInfo return medal all info.
  38. func (r *RPC) MedalAllInfo(c context.Context, arg *model.ArgMid, res *model.MedalAllInfos) (err error) {
  39. var mai *model.MedalAllInfos
  40. if mai, err = r.s.MedalAllInfo(c, arg.Mid); err == nil && mai != nil {
  41. *res = *mai
  42. }
  43. return
  44. }
  45. // MedalGrant send a medal to user.
  46. func (r *RPC) MedalGrant(c context.Context, arg *model.ArgMIDNID, res *struct{}) (err error) {
  47. err = r.s.MedalGet(c, arg.MID, arg.NID)
  48. return
  49. }
  50. // MedalActivated get the user activated medal info.
  51. func (r *RPC) MedalActivated(c context.Context, arg *model.ArgMid, res *model.MedalInfo) (err error) {
  52. var ma *model.MedalInfo
  53. if ma, err = r.s.MedalActivated(c, arg.Mid); err == nil && ma != nil {
  54. *res = *ma
  55. }
  56. return
  57. }
  58. // MedalActivatedMulti Multi get get the user activated medal info(at most 50).
  59. func (r *RPC) MedalActivatedMulti(c context.Context, arg *model.ArgMids, res *map[int64]*model.MedalInfo) (err error) {
  60. *res, err = r.s.MedalActivatedMulti(c, arg.Mids)
  61. return
  62. }