controller.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. package video
  2. import (
  3. "net/http"
  4. "bet24.com/log"
  5. "github.com/gin-gonic/gin"
  6. )
  7. // 广告播放统计(按天)
  8. func PlayStat(c *gin.Context) {
  9. var req req_base
  10. if err := c.ShouldBind(&req); err != nil {
  11. log.Debug("%s shouldBind err %v", "video.PlayStat", err)
  12. return
  13. }
  14. var resp struct {
  15. List interface{}
  16. TotalReqTimes int
  17. TotalPlayTimes int
  18. TotalFailTimes int
  19. }
  20. resp.TotalReqTimes, resp.TotalPlayTimes, resp.TotalFailTimes, resp.List = mgr.playStat(req.BeginTime, req.EndTime, req.PartnerID)
  21. c.JSON(http.StatusOK, resp)
  22. return
  23. }
  24. // 广告播放统计(按时段)
  25. func PlayStatByHour(c *gin.Context) {
  26. obj := NewPlayStatByHour()
  27. if err := c.ShouldBind(&obj.In); err != nil {
  28. log.Debug("%s shouldBind err %v", "video.PlayStatByHour", err)
  29. return
  30. }
  31. obj.DoAction()
  32. c.JSON(http.StatusOK, obj.Out)
  33. return
  34. }
  35. // 广告来源统计
  36. func SourceList(c *gin.Context) {
  37. var req req_base
  38. if err := c.ShouldBind(&req); err != nil {
  39. log.Debug("%s shouldBind err %v", "video.SourceList", err)
  40. return
  41. }
  42. list := mgr.sourceStat(req.BeginTime, req.EndTime, req.PartnerID)
  43. c.JSON(http.StatusOK, struct {
  44. List interface{}
  45. }{
  46. List: list,
  47. })
  48. return
  49. }
  50. // 广告分布
  51. func RegionList(c *gin.Context) {
  52. obj := NewRegionList()
  53. if err := c.ShouldBind(&obj.In); err != nil {
  54. log.Debug("%s shouldBind err %v", "video.RegionList", err)
  55. return
  56. }
  57. obj.DoAction()
  58. c.JSON(http.StatusOK, obj.Out)
  59. return
  60. }
  61. // 广告指标
  62. func IndexList(c *gin.Context) {
  63. var req req_base
  64. if err := c.ShouldBind(&req); err != nil {
  65. log.Debug("%s shouldBind err %v", "video.IndexList", err)
  66. return
  67. }
  68. list := mgr.indexStat(req.BeginTime, req.EndTime)
  69. c.JSON(http.StatusOK, struct {
  70. List interface{}
  71. }{
  72. List: list,
  73. })
  74. return
  75. }
  76. // 广告用户统计(按天)
  77. func UserStat(c *gin.Context) {
  78. var req req_base
  79. if err := c.ShouldBind(&req); err != nil {
  80. log.Debug("%s shouldBind err %v", "video.UserStat", err)
  81. return
  82. }
  83. list := mgr.userStat(req.BeginTime, req.EndTime)
  84. c.JSON(http.StatusOK, struct {
  85. List interface{}
  86. }{
  87. List: list,
  88. })
  89. return
  90. }
  91. // 广告用户统计(按时段)
  92. func UserStatByHour(c *gin.Context) {
  93. obj := NewUserStatByHour()
  94. if err := c.ShouldBind(&obj.In); err != nil {
  95. log.Debug("%s shouldBind err %v", "video.UserStatByHour", err)
  96. return
  97. }
  98. obj.DoAction()
  99. c.JSON(http.StatusOK, obj.Out)
  100. return
  101. }