video.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. package http
  2. import (
  3. "go-common/app/admin/main/tv/model"
  4. "go-common/library/ecode"
  5. bm "go-common/library/net/http/blademaster"
  6. )
  7. // VideoList get ugc video list
  8. func VideoList(c *bm.Context) {
  9. var (
  10. res = map[string]interface{}{}
  11. err error
  12. pager *model.VideoListPager
  13. )
  14. param := new(model.VideoListParam)
  15. if err = c.Bind(param); err != nil {
  16. c.JSON(nil, ecode.RequestErr)
  17. return
  18. }
  19. if pager, err = tvSrv.VideoList(c, param); err != nil {
  20. res["message"] = "获取数据失败!" + err.Error()
  21. c.JSONMap(res, ecode.RequestErr)
  22. return
  23. }
  24. c.JSON(pager, nil)
  25. }
  26. // VideoOnline online ugc video
  27. func VideoOnline(c *bm.Context) {
  28. var (
  29. err error
  30. res = map[string]interface{}{}
  31. )
  32. param := new(struct {
  33. IDs []int64 `form:"ids,split" validate:"required,min=1,dive,gt=0"`
  34. })
  35. if err = c.Bind(param); err != nil {
  36. return
  37. }
  38. if err := tvSrv.VideoOnline(param.IDs); err != nil {
  39. res["message"] = "更新数据失败!" + err.Error()
  40. c.JSONMap(res, ecode.RequestErr)
  41. return
  42. }
  43. c.JSON("成功", nil)
  44. }
  45. // VideoHidden hidden ugc video
  46. func VideoHidden(c *bm.Context) {
  47. var (
  48. err error
  49. res = map[string]interface{}{}
  50. )
  51. param := new(struct {
  52. IDs []int64 `form:"ids,split" validate:"required,min=1,dive,gt=0"`
  53. })
  54. if err = c.Bind(param); err != nil {
  55. return
  56. }
  57. if err := tvSrv.VideoHidden(param.IDs); err != nil {
  58. res["message"] = "更新数据失败!" + err.Error()
  59. c.JSONMap(res, ecode.RequestErr)
  60. return
  61. }
  62. c.JSON("成功", nil)
  63. }
  64. // VideoPreview ugc video preview
  65. func VideoPreview(c *bm.Context) {
  66. var (
  67. playurl string
  68. err error
  69. res = map[string]interface{}{}
  70. )
  71. param := new(struct {
  72. ID int `form:"id" validate:"required"`
  73. })
  74. if err = c.Bind(param); err != nil {
  75. return
  76. }
  77. if playurl, err = tvSrv.UPlayurl(param.ID); err != nil {
  78. res["message"] = "获取playurl失败" + err.Error()
  79. c.JSONMap(res, ecode.RequestErr)
  80. return
  81. }
  82. c.JSON(playurl, nil)
  83. }
  84. // videoUpdate ugc video update
  85. func videoUpdate(c *bm.Context) {
  86. var (
  87. err error
  88. res = map[string]interface{}{}
  89. )
  90. param := new(struct {
  91. ID int `form:"id" validate:"required"`
  92. Title string `form:"title" validate:"required"`
  93. })
  94. if err = c.Bind(param); err != nil {
  95. return
  96. }
  97. if err = tvSrv.VideoUpdate(param.ID, param.Title); err != nil {
  98. res["message"] = "更新失败" + err.Error()
  99. c.JSONMap(res, ecode.RequestErr)
  100. return
  101. }
  102. c.JSON(nil, nil)
  103. }
  104. func abnorExport(c *bm.Context) {
  105. buf, fileName := tvSrv.AbnormExport()
  106. c.Writer.Header().Set("Content-Type", "application/csv")
  107. c.Writer.Header().Set("Content-Disposition", fileName)
  108. c.Writer.Write(buf.Bytes())
  109. }
  110. func abnorDebug(c *bm.Context) {
  111. c.JSON(tvSrv.AbnDebug(), nil)
  112. }