stat.go 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. package http
  2. import (
  3. "fmt"
  4. "go-common/library/ecode"
  5. bm "go-common/library/net/http/blademaster"
  6. "go-common/library/xstr"
  7. "net/http"
  8. "sort"
  9. "time"
  10. )
  11. func recheckPanel(c *bm.Context) {
  12. v := new(struct {
  13. TypeIDStr string `form:"type_id"`
  14. StartDate int64 `form:"start_date"`
  15. EndDate int64 `form:"end_date"`
  16. UName string `form:"uname"`
  17. })
  18. err := c.Bind(v)
  19. if err != nil {
  20. c.JSON(nil, ecode.RequestErr)
  21. return
  22. }
  23. var typeIDS []int64
  24. if typeIDS, err = xstr.SplitInts(v.TypeIDStr); err != nil {
  25. c.JSON(nil, err)
  26. return
  27. }
  28. recheckViews, err := svc.ArchiveRecheck(c, typeIDS, v.UName, v.StartDate, v.EndDate)
  29. if err != nil {
  30. c.JSON(nil, err)
  31. return
  32. }
  33. sort.Slice(recheckViews, func(i, j int) bool {
  34. return recheckViews[i].Date > recheckViews[j].Date
  35. })
  36. c.JSON(recheckViews, nil)
  37. }
  38. func recheckUser(c *bm.Context) {
  39. v := new(struct {
  40. TypeIDStr string `form:"type_id"`
  41. StartDate int64 `form:"start_date"`
  42. EndDate int64 `form:"end_date"`
  43. UName string `form:"uname"`
  44. })
  45. err := c.Bind(v)
  46. if err != nil {
  47. c.JSON(nil, ecode.RequestErr)
  48. return
  49. }
  50. var typeIDS []int64
  51. if typeIDS, err = xstr.SplitInts(v.TypeIDStr); err != nil {
  52. c.JSON(nil, err)
  53. return
  54. }
  55. recheckViews, err := svc.UserRecheck(c, typeIDS, v.UName, v.StartDate, v.EndDate)
  56. if err != nil {
  57. c.JSON(nil, err)
  58. return
  59. }
  60. sort.Slice(recheckViews, func(i, j int) bool {
  61. return recheckViews[i].Date > recheckViews[j].Date
  62. })
  63. c.JSON(recheckViews, nil)
  64. }
  65. func auditCargoCsv(c *bm.Context) {
  66. v := new(struct {
  67. StartDate int64 `form:"stime"`
  68. EndDate int64 `form:"etime"`
  69. Uname string `form:"uname"`
  70. })
  71. err := c.Bind(v)
  72. if err != nil {
  73. c.JSON(nil, ecode.RequestErr)
  74. return
  75. }
  76. content, err := svc.CsvAuditCargo(c, v.StartDate, v.EndDate, v.Uname)
  77. if err != nil {
  78. c.JSON(nil, err)
  79. return
  80. }
  81. c.Render(http.StatusOK, CSV{
  82. Content: content,
  83. Title: fmt.Sprintf("%s~%s-%s", time.Unix(v.StartDate, 0).Format("2006/01/02_15"), time.Unix(v.EndDate, 0).Format("2006/01/02_15"), v.Uname),
  84. })
  85. }
  86. func auditorCargo(c *bm.Context) {
  87. v := new(struct {
  88. StartDate int64 `form:"stime"`
  89. EndDate int64 `form:"etime"`
  90. Uname string `form:"uname"`
  91. })
  92. err := c.Bind(v)
  93. if err != nil {
  94. c.JSON(nil, ecode.RequestErr)
  95. return
  96. }
  97. wrappers, _, err := svc.AuditorCargoList(c, v.StartDate, v.EndDate, v.Uname)
  98. if err != nil {
  99. c.JSON(nil, err)
  100. return
  101. }
  102. sort.Slice(wrappers, func(i, j int) bool {
  103. return wrappers[i].Date > wrappers[j].Date
  104. })
  105. c.JSON(wrappers, nil)
  106. }
  107. func tagRecheck(c *bm.Context) {
  108. v := new(struct {
  109. Uname string `form:"uname"`
  110. StartDate int64 `form:"stime"`
  111. EndDate int64 `form:"etime"`
  112. })
  113. err := c.Bind(v)
  114. if err != nil {
  115. c.JSON(nil, ecode.RequestErr)
  116. return
  117. }
  118. tagViews, err := svc.TagRecheck(c, v.StartDate, v.EndDate, v.Uname)
  119. if err != nil {
  120. c.JSON(nil, err)
  121. return
  122. }
  123. sort.Slice(tagViews, func(i, j int) bool {
  124. return tagViews[i].Date > tagViews[j].Date
  125. })
  126. c.JSON(tagViews, nil)
  127. }
  128. func recheck123(c *bm.Context) {
  129. v := new(struct {
  130. StartDate int64 `form:"stime"`
  131. EndDate int64 `form:"etime"`
  132. TypeIDStr string `form:"type_id"`
  133. })
  134. err := c.Bind(v)
  135. if err != nil {
  136. c.JSON(nil, ecode.RequestErr)
  137. return
  138. }
  139. var typeIDS []int64
  140. if typeIDS, err = xstr.SplitInts(v.TypeIDStr); err != nil {
  141. c.JSON(nil, err)
  142. return
  143. }
  144. recheckViews, err := svc.Recheck123(c, v.StartDate, v.EndDate, typeIDS)
  145. if err != nil {
  146. c.JSON(nil, err)
  147. return
  148. }
  149. sort.Slice(recheckViews, func(i, j int) bool {
  150. return recheckViews[i].Date > recheckViews[j].Date
  151. })
  152. c.JSON(recheckViews, nil)
  153. }
  154. func randomVideo(c *bm.Context) {
  155. v := new(struct {
  156. StartDate int64 `form:"stime"`
  157. EndDate int64 `form:"etime"`
  158. TypeIDStr string `form:"type_id"`
  159. Uname string `form:"uname"`
  160. })
  161. err := c.Bind(v)
  162. if err != nil {
  163. c.JSON(nil, ecode.RequestErr)
  164. return
  165. }
  166. var typeIDS []int64
  167. if typeIDS, err = xstr.SplitInts(v.TypeIDStr); err != nil {
  168. c.JSON(nil, err)
  169. return
  170. }
  171. statViewExts, _, err := svc.RandomVideo(c, v.StartDate, v.EndDate, typeIDS, v.Uname)
  172. if err != nil {
  173. c.JSON(nil, err)
  174. return
  175. }
  176. sort.Slice(statViewExts, func(i, j int) bool {
  177. return statViewExts[i].Date > statViewExts[j].Date
  178. })
  179. c.JSON(statViewExts, nil)
  180. }
  181. func fixedVideo(c *bm.Context) {
  182. v := new(struct {
  183. StartDate int64 `form:"stime"`
  184. EndDate int64 `form:"etime"`
  185. TypeIDStr string `form:"type_id"`
  186. Uname string `form:"uname"`
  187. })
  188. err := c.Bind(v)
  189. if err != nil {
  190. c.JSON(nil, ecode.RequestErr)
  191. return
  192. }
  193. var typeIDS []int64
  194. if typeIDS, err = xstr.SplitInts(v.TypeIDStr); err != nil {
  195. c.JSON(nil, err)
  196. return
  197. }
  198. statViewExts, _, err := svc.FixedVideo(c, v.StartDate, v.EndDate, typeIDS, v.Uname)
  199. if err != nil {
  200. c.JSON(nil, err)
  201. return
  202. }
  203. sort.Slice(statViewExts, func(i, j int) bool {
  204. return statViewExts[i].Date > statViewExts[j].Date
  205. })
  206. c.JSON(statViewExts, nil)
  207. }
  208. func csvFixedVideo(c *bm.Context) {
  209. v := new(struct {
  210. StartDate int64 `form:"stime"`
  211. EndDate int64 `form:"etime"`
  212. Uname string `form:"uname"`
  213. TypeIDStr string `form:"type_id"`
  214. })
  215. err := c.Bind(v)
  216. if err != nil {
  217. c.JSON(nil, ecode.RequestErr)
  218. return
  219. }
  220. var typeIDS []int64
  221. if typeIDS, err = xstr.SplitInts(v.TypeIDStr); err != nil {
  222. c.JSON(nil, err)
  223. return
  224. }
  225. content, err := svc.CsvFixedVideoAudit(c, v.StartDate, v.EndDate, v.Uname, typeIDS)
  226. if err != nil {
  227. c.JSON(nil, err)
  228. return
  229. }
  230. c.Render(http.StatusOK, CSV{
  231. Content: content,
  232. Title: fmt.Sprintf("%s_%s~%s-%s", "(定时发布)视频审核操作数据", time.Unix(v.StartDate, 0).Format("2006-01-02"), time.Unix(v.EndDate, 0).Format("2006-01-02"), v.Uname),
  233. })
  234. }
  235. func csvRandomVideo(c *bm.Context) {
  236. v := new(struct {
  237. StartDate int64 `form:"stime"`
  238. EndDate int64 `form:"etime"`
  239. Uname string `form:"uname"`
  240. TypeIDStr string `form:"type_id"`
  241. })
  242. err := c.Bind(v)
  243. if err != nil {
  244. c.JSON(nil, ecode.RequestErr)
  245. return
  246. }
  247. var typeIDS []int64
  248. if typeIDS, err = xstr.SplitInts(v.TypeIDStr); err != nil {
  249. c.JSON(nil, err)
  250. return
  251. }
  252. content, err := svc.CsvRandomVideoAudit(c, v.StartDate, v.EndDate, v.Uname, typeIDS)
  253. if err != nil {
  254. c.JSON(nil, err)
  255. return
  256. }
  257. c.Render(http.StatusOK, CSV{
  258. Content: content,
  259. Title: fmt.Sprintf("%s_%s~%s-%s", "(非定时)视频审核操作数据", time.Unix(v.StartDate, 0).Format("2006-01-02"), time.Unix(v.EndDate, 0).Format("2006-01-02"), v.Uname),
  260. })
  261. }