medal.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package http
  2. import (
  3. "strconv"
  4. "go-common/app/service/main/usersuit/model"
  5. "go-common/library/ecode"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. func medalUserInfo(c *bm.Context) {
  9. var (
  10. err error
  11. mid, _ = c.Get("mid")
  12. //ip = c.RemoteIP()
  13. data *model.MedalUserInfo
  14. )
  15. if data, err = memberSvc.MedalUserInfo(c, mid.(int64)); err != nil {
  16. c.JSON(nil, err)
  17. return
  18. }
  19. c.JSON(data, nil)
  20. }
  21. func medalInstall(c *bm.Context) {
  22. var (
  23. err error
  24. nid, isActivated int64
  25. mid, _ = c.Get("mid")
  26. )
  27. nidStr := c.Request.Form.Get("nid")
  28. if nid, err = strconv.ParseInt(nidStr, 10, 64); err != nil {
  29. c.JSON(nil, ecode.RequestErr)
  30. return
  31. }
  32. isActivatedStr := c.Request.Form.Get("isActivated")
  33. if isActivated, err = strconv.ParseInt(isActivatedStr, 10, 64); err != nil {
  34. c.JSON(nil, ecode.RequestErr)
  35. return
  36. }
  37. err = memberSvc.MedalInstall(c, mid.(int64), nid, int8(isActivated))
  38. if err != nil {
  39. c.JSON(nil, err)
  40. return
  41. }
  42. c.JSON(nil, nil)
  43. }
  44. func medalPopup(c *bm.Context) {
  45. var (
  46. err error
  47. mid, _ = c.Get("mid")
  48. data *model.MedalPopup
  49. )
  50. if data, err = memberSvc.MedalPopup(c, mid.(int64)); err != nil {
  51. c.JSON(nil, err)
  52. return
  53. }
  54. c.JSON(data, nil)
  55. }
  56. func medalMyInfo(c *bm.Context) {
  57. var (
  58. mid, _ = c.Get("mid")
  59. )
  60. data, err := memberSvc.MedalMyInfo(c, mid.(int64))
  61. if err != nil {
  62. c.JSON(nil, err)
  63. return
  64. }
  65. c.JSON(data, nil)
  66. }
  67. func medalAllInfo(c *bm.Context) {
  68. var (
  69. mid, _ = c.Get("mid")
  70. )
  71. data, err := memberSvc.MedalAllInfo(c, mid.(int64))
  72. if err != nil {
  73. c.JSON(nil, err)
  74. return
  75. }
  76. c.JSON(data, nil)
  77. }