special_award.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. package http
  2. import (
  3. "go-common/library/ecode"
  4. "go-common/library/log"
  5. bm "go-common/library/net/http/blademaster"
  6. )
  7. func sepcialAwardInfo(c *bm.Context) {
  8. var mid int64
  9. midI, ok := c.Get("mid")
  10. if ok {
  11. mid, _ = midI.(int64)
  12. }
  13. data, err := svc.SpecialAwardInfo(c, mid)
  14. if err != nil {
  15. log.Error("svc.SpecialAwardInfo error(%v)", err)
  16. c.JSON(nil, err)
  17. return
  18. }
  19. c.JSON(data, nil)
  20. }
  21. func specialAwardDetail(c *bm.Context) {
  22. v := new(struct {
  23. AwardID int64 `form:"award_id" validate:"required"`
  24. })
  25. if err := c.Bind(v); err != nil {
  26. return
  27. }
  28. data, err := svc.AwardDetail(c, v.AwardID)
  29. if err != nil {
  30. log.Error("svc.AwardDetail error(%v)", err)
  31. c.JSON(nil, err)
  32. return
  33. }
  34. c.JSON(data, nil)
  35. }
  36. func listSpecialAward(c *bm.Context) {
  37. data, err := svc.AwardList(c)
  38. if err != nil {
  39. log.Error("svc.AwardDetail error(%v)", err)
  40. c.JSON(nil, err)
  41. return
  42. }
  43. c.JSON(data, nil)
  44. }
  45. func specialAwardRecord(c *bm.Context) {
  46. midI, ok := c.Get("mid")
  47. if !ok {
  48. c.JSON(nil, ecode.NoLogin)
  49. return
  50. }
  51. mid, _ := midI.(int64)
  52. data, err := svc.GetWinningRecord(c, mid)
  53. if err != nil {
  54. log.Error("svc.AwardDetail error(%v)", err)
  55. c.JSON(nil, err)
  56. return
  57. }
  58. c.JSON(data, nil)
  59. }
  60. func specialAwardPoster(c *bm.Context) {
  61. midI, ok := c.Get("mid")
  62. if !ok {
  63. c.JSON(nil, ecode.NoLogin)
  64. return
  65. }
  66. mid, _ := midI.(int64)
  67. v := new(struct {
  68. AwardID int64 `form:"award_id" validate:"required"`
  69. PrizeID int64 `form:"prize_id" validate:"required"`
  70. })
  71. if err := c.Bind(v); err != nil {
  72. return
  73. }
  74. data, err := svc.GetWinningPoster(c, mid, v.AwardID, v.PrizeID)
  75. if err != nil {
  76. log.Error("svc.AwardDetail error(%v)", err)
  77. c.JSON(nil, err)
  78. return
  79. }
  80. c.JSON(data, nil)
  81. }
  82. func joinSpecialAward(c *bm.Context) {
  83. midI, ok := c.Get("mid")
  84. if !ok {
  85. c.JSON(nil, ecode.NoLogin)
  86. return
  87. }
  88. mid, _ := midI.(int64)
  89. v := new(struct {
  90. AwardID int64 `form:"award_id" validate:"required"`
  91. })
  92. if err := c.Bind(v); err != nil {
  93. return
  94. }
  95. err := svc.JoinAward(c, mid, v.AwardID)
  96. if err != nil {
  97. log.Error("svc.AwardDetail error(%v)", err)
  98. c.JSON(nil, err)
  99. return
  100. }
  101. c.JSON(nil, err)
  102. }
  103. func specialAwardWinners(c *bm.Context) {
  104. v := new(struct {
  105. AwardID int64 `form:"award_id" validate:"required"`
  106. })
  107. if err := c.Bind(v); err != nil {
  108. return
  109. }
  110. data, err := svc.Winners(c, v.AwardID)
  111. if err != nil {
  112. log.Error("svc.AwardDetail error(%v)", err)
  113. c.JSON(nil, err)
  114. return
  115. }
  116. c.JSON(data, nil)
  117. }
  118. func specialAwardUpStatus(c *bm.Context) {
  119. midI, ok := c.Get("mid")
  120. if !ok {
  121. c.JSON(nil, ecode.NoLogin)
  122. return
  123. }
  124. mid, _ := midI.(int64)
  125. v := new(struct {
  126. AwardID int64 `form:"award_id" validate:"required"`
  127. })
  128. if err := c.Bind(v); err != nil {
  129. return
  130. }
  131. data, err := svc.GetAwardUpStatus(c, v.AwardID, mid)
  132. if err != nil {
  133. log.Error("svc.GetAwardUpStatus error(%v)", err)
  134. c.JSON(nil, err)
  135. return
  136. }
  137. c.JSON(data, nil)
  138. }