cheat.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. package http
  2. import (
  3. "fmt"
  4. "net/http"
  5. "time"
  6. "go-common/library/log"
  7. bm "go-common/library/net/http/blademaster"
  8. "go-common/library/net/http/blademaster/render"
  9. )
  10. func cheatUps(c *bm.Context) {
  11. v := new(struct {
  12. MID int64 `form:"mid"`
  13. Nickname string `form:"nickname"`
  14. From int `form:"from" validate:"min=0" default:"0"`
  15. Limit int `form:"limit" validate:"min=1" default:"20"`
  16. })
  17. if err := c.Bind(v); err != nil {
  18. return
  19. }
  20. total, spies, err := svr.CheatUps(c, v.MID, v.Nickname, v.From, v.Limit)
  21. if err != nil {
  22. log.Error("growup svr.CheatUps error(%v)", err)
  23. c.JSON(nil, err)
  24. return
  25. }
  26. c.Render(http.StatusOK, render.MapJSON(map[string]interface{}{
  27. "code": 0,
  28. "message": "0",
  29. "data": spies,
  30. "paging": map[string]int{
  31. "page_size": v.Limit,
  32. "total": total,
  33. },
  34. }))
  35. }
  36. func cheatArchives(c *bm.Context) {
  37. v := new(struct {
  38. MID int64 `form:"mid"`
  39. ArchiveID int64 `form:"archive_id"`
  40. Nickname string `form:"nickname"`
  41. From int `form:"from" validate:"min=0" default:"0"`
  42. Limit int `form:"limit" validate:"min=1" default:"20"`
  43. })
  44. if err := c.Bind(v); err != nil {
  45. return
  46. }
  47. total, spies, err := svr.CheatArchives(c, v.MID, v.ArchiveID, v.Nickname, v.From, v.Limit)
  48. if err != nil {
  49. log.Error("growup svr.CheatUps error(%v)", err)
  50. c.JSON(nil, err)
  51. return
  52. }
  53. c.Render(http.StatusOK, render.MapJSON(map[string]interface{}{
  54. "code": 0,
  55. "message": "0",
  56. "data": spies,
  57. "paging": map[string]int{
  58. "page_size": v.Limit,
  59. "total": total,
  60. },
  61. }))
  62. }
  63. func exportCheatUps(c *bm.Context) {
  64. v := new(struct {
  65. MID int64 `form:"mid"`
  66. Nickname string `form:"nickname"`
  67. From int `form:"from" validate:"min=0" default:"0"`
  68. Limit int `form:"limit" validate:"min=1" default:"20"`
  69. })
  70. if err := c.Bind(v); err != nil {
  71. return
  72. }
  73. content, err := svr.ExportCheatUps(c, v.MID, v.Nickname, v.From, v.Limit)
  74. if err != nil {
  75. log.Error("s.exportSpyUp ExportSpyUp error(%v)", err)
  76. c.JSON(nil, err)
  77. return
  78. }
  79. c.Render(http.StatusOK, CSV{
  80. Content: content,
  81. Title: fmt.Sprintf("%s-%s", time.Now().Format("2006-01-02"), "cheat_ups"),
  82. })
  83. }
  84. func exportCheatAvs(c *bm.Context) {
  85. v := new(struct {
  86. MID int64 `form:"mid"`
  87. Nickname string `form:"nickname"`
  88. ArchiveID int64 `form:"archive_id"`
  89. From int `form:"from" validate:"min=0" default:"0"`
  90. Limit int `form:"limit" validate:"min=1" default:"20"`
  91. })
  92. if err := c.Bind(v); err != nil {
  93. return
  94. }
  95. content, err := svr.ExportCheatAvs(c, v.MID, v.ArchiveID, v.Nickname, v.From, v.Limit)
  96. if err != nil {
  97. log.Error("s.exportSpyAV ExportSpyAV error(%v)", err)
  98. c.JSON(nil, err)
  99. return
  100. }
  101. c.Render(http.StatusOK, CSV{
  102. Content: content,
  103. Title: fmt.Sprintf("%s-%s", time.Now().Format("2006-01-02"), "cheat_avs"),
  104. })
  105. }
  106. func queryCheatFans(c *bm.Context) {
  107. v := new(struct {
  108. From int64 `form:"from" default:"0" validate:"min=0"`
  109. Limit int64 `form:"limit" default:"20" validate:"min=1"`
  110. })
  111. if err := c.Bind(v); err != nil {
  112. return
  113. }
  114. total, fans, err := svr.QueryCheatFans(c, v.From, v.Limit)
  115. if err != nil {
  116. log.Error("growup svr.QueryCheatFans error(%v)", err)
  117. c.JSON(nil, err)
  118. return
  119. }
  120. c.Render(http.StatusOK, render.MapJSON(map[string]interface{}{
  121. "code": 0,
  122. "data": fans,
  123. "paging": map[string]int64{
  124. "page_size": v.Limit,
  125. "total": total,
  126. },
  127. }))
  128. }
  129. func cheatFans(c *bm.Context) {
  130. v := new(struct {
  131. MID int64 `form:"mid"`
  132. })
  133. if err := c.Bind(v); err != nil {
  134. return
  135. }
  136. err := svr.CheatFans(c, v.MID)
  137. if err != nil {
  138. log.Error("Exec cheatFans error!(%v)", err)
  139. }
  140. c.JSON(nil, err)
  141. }