medal.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. package http
  2. import (
  3. "go-common/app/service/main/usersuit/model"
  4. bm "go-common/library/net/http/blademaster"
  5. "go-common/library/net/metadata"
  6. )
  7. func medalInfo(c *bm.Context) {
  8. var (
  9. err error
  10. info *model.MedalInfo
  11. arg = new(model.ArgMIDNID)
  12. )
  13. if err = c.Bind(arg); err != nil {
  14. return
  15. }
  16. if info, err = usersuitSvc.MedalInfo(c, arg.MID, arg.NID); err != nil {
  17. c.JSON(nil, err)
  18. return
  19. }
  20. c.JSON(info, nil)
  21. }
  22. func medalGet(c *bm.Context) {
  23. var (
  24. err error
  25. arg = new(model.ArgMIDNID)
  26. )
  27. if err = c.Bind(arg); err != nil {
  28. return
  29. }
  30. if err = usersuitSvc.MedalGet(c, arg.MID, arg.NID); err != nil {
  31. c.JSON(nil, err)
  32. return
  33. }
  34. c.JSON(nil, nil)
  35. }
  36. func medalCheck(c *bm.Context) {
  37. var (
  38. err error
  39. info *model.MedalCheck
  40. arg = new(model.ArgMIDNID)
  41. )
  42. if err = c.Bind(arg); err != nil {
  43. return
  44. }
  45. if info, err = usersuitSvc.MedalCheck(c, arg.MID, arg.NID); err != nil {
  46. c.JSON(nil, err)
  47. return
  48. }
  49. c.JSON(info, nil)
  50. }
  51. func medalActivated(c *bm.Context) {
  52. var (
  53. err error
  54. arg = new(model.ArgMID)
  55. )
  56. if err = c.Bind(arg); err != nil {
  57. return
  58. }
  59. c.JSON(usersuitSvc.MedalActivated(c, arg.MID))
  60. }
  61. func medalMy(c *bm.Context) {
  62. var (
  63. err error
  64. arg = new(model.ArgMID)
  65. )
  66. if err = c.Bind(arg); err != nil {
  67. return
  68. }
  69. c.JSON(usersuitSvc.MedalMyInfo(c, arg.MID))
  70. }
  71. func medalAllInfo(c *bm.Context) {
  72. var (
  73. err error
  74. arg = new(model.ArgMID)
  75. )
  76. if err = c.Bind(arg); err != nil {
  77. return
  78. }
  79. c.JSON(usersuitSvc.MedalAllInfo(c, arg.MID))
  80. }
  81. func medalPopup(c *bm.Context) {
  82. var (
  83. err error
  84. arg = new(model.ArgMID)
  85. )
  86. if err = c.Bind(arg); err != nil {
  87. return
  88. }
  89. c.JSON(usersuitSvc.MedalPopup(c, arg.MID))
  90. }
  91. func medalInstall(c *bm.Context) {
  92. var (
  93. err error
  94. arg = new(model.ArgMedalInstall)
  95. )
  96. if err = c.Bind(arg); err != nil {
  97. return
  98. }
  99. c.JSON(nil, usersuitSvc.MedalInstall(c, arg.Mid, arg.Nid, arg.IsActivated))
  100. }
  101. func medalUser(c *bm.Context) {
  102. var (
  103. err error
  104. arg = new(model.ArgMID)
  105. )
  106. if err = c.Bind(arg); err != nil {
  107. return
  108. }
  109. c.JSON(usersuitSvc.MedalUserInfo(c, arg.MID, metadata.String(c, metadata.RemoteIP)))
  110. }