user.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. package http
  2. import (
  3. "strconv"
  4. "go-common/app/admin/main/spy/model"
  5. "go-common/library/ecode"
  6. "go-common/library/log"
  7. bm "go-common/library/net/http/blademaster"
  8. )
  9. func userInfo(c *bm.Context) {
  10. var (
  11. params = c.Request.Form
  12. mid int64
  13. err error
  14. )
  15. mid, err = strconv.ParseInt(params.Get("mid"), 10, 64)
  16. if err != nil {
  17. c.JSON(nil, ecode.RequestErr)
  18. return
  19. }
  20. data, err := spySrv.UserInfo(c, mid)
  21. if err != nil {
  22. log.Error("spySrv.UserInfo error(%v)", err)
  23. c.JSON(nil, err)
  24. return
  25. }
  26. c.JSON(data, err)
  27. }
  28. func historyPage(c *bm.Context) {
  29. var (
  30. params = c.Request.Form
  31. mid int64
  32. pn, ps int
  33. err error
  34. data *model.HistoryPage
  35. )
  36. mid, err = strconv.ParseInt(params.Get("mid"), 10, 64)
  37. if err != nil {
  38. c.JSON(nil, ecode.RequestErr)
  39. return
  40. }
  41. if ps, err = strconv.Atoi(params.Get("ps")); err != nil {
  42. ps = model.DefPs
  43. }
  44. if pn, err = strconv.Atoi(params.Get("pn")); err != nil {
  45. pn = model.DefPn
  46. }
  47. q := &model.HisParamReq{Mid: mid, Pn: pn, Ps: ps}
  48. data, err = spySrv.HisoryPage(c, q)
  49. if err != nil {
  50. log.Error("spySrv.HisoryPage error(%v)", err)
  51. c.JSON(nil, err)
  52. return
  53. }
  54. c.JSON(data, err)
  55. }
  56. func resetBase(c *bm.Context) {
  57. var (
  58. params = c.Request.Form
  59. name = params.Get("name")
  60. mid int64
  61. err error
  62. )
  63. if name == "" {
  64. c.JSON(nil, ecode.RequestErr)
  65. return
  66. }
  67. mid, err = strconv.ParseInt(params.Get("mid"), 10, 64)
  68. if err != nil {
  69. c.JSON(nil, ecode.RequestErr)
  70. return
  71. }
  72. err = spySrv.ResetBase(c, mid, name)
  73. if err != nil {
  74. log.Error("spySrv.ResetBase error(%v)", err)
  75. c.JSON(nil, err)
  76. return
  77. }
  78. c.JSON(nil, err)
  79. }
  80. func refreshBase(c *bm.Context) {
  81. var (
  82. params = c.Request.Form
  83. name = params.Get("name")
  84. mid int64
  85. err error
  86. )
  87. if name == "" {
  88. c.JSON(nil, ecode.RequestErr)
  89. return
  90. }
  91. mid, err = strconv.ParseInt(params.Get("mid"), 10, 64)
  92. if err != nil {
  93. c.JSON(nil, ecode.RequestErr)
  94. return
  95. }
  96. err = spySrv.RefreshBase(c, mid, name)
  97. if err != nil {
  98. log.Error("spySrv.RefreshBase error(%v)", err)
  99. c.JSON(nil, err)
  100. return
  101. }
  102. c.JSON(nil, err)
  103. }
  104. func resetEvent(c *bm.Context) {
  105. var (
  106. params = c.Request.Form
  107. name = params.Get("name")
  108. mid int64
  109. err error
  110. )
  111. if name == "" {
  112. c.JSON(nil, ecode.RequestErr)
  113. return
  114. }
  115. mid, err = strconv.ParseInt(params.Get("mid"), 10, 64)
  116. if err != nil {
  117. c.JSON(nil, ecode.RequestErr)
  118. return
  119. }
  120. err = spySrv.ResetEvent(c, mid, name)
  121. if err != nil {
  122. log.Error("spySrv.ResetEvent error(%v)", err)
  123. c.JSON(nil, err)
  124. return
  125. }
  126. c.JSON(nil, err)
  127. }
  128. func clearCount(c *bm.Context) {
  129. var (
  130. params = c.Request.Form
  131. name = params.Get("name")
  132. mid int64
  133. err error
  134. )
  135. if name == "" {
  136. c.JSON(nil, ecode.RequestErr)
  137. return
  138. }
  139. mid, err = strconv.ParseInt(params.Get("mid"), 10, 64)
  140. if err != nil {
  141. c.JSON(nil, ecode.RequestErr)
  142. return
  143. }
  144. err = spySrv.ClearCount(c, mid, name)
  145. if err != nil {
  146. log.Error("spySrv.ClearCount error(%v)", err)
  147. c.JSON(nil, err)
  148. return
  149. }
  150. c.JSON(nil, err)
  151. }