qa_video.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. package http
  2. import (
  3. "strconv"
  4. "time"
  5. "go-common/app/admin/main/videoup-task/model"
  6. "go-common/library/ecode"
  7. "go-common/library/log"
  8. bm "go-common/library/net/http/blademaster"
  9. "go-common/library/net/http/blademaster/binding"
  10. )
  11. func list(ctx *bm.Context) {
  12. params := new(model.ListParams)
  13. if err := ctx.Bind(params); err != nil {
  14. ctx.JSON(nil, ecode.RequestErr)
  15. return
  16. }
  17. if params.Limit > 0 && (params.Limit <= (params.Pn-1)*params.Ps || params.Seed == "") {
  18. ctx.JSON(nil, ecode.RequestErr)
  19. return
  20. }
  21. //params 默认值
  22. tformat := "2006-01-02 15:04:05"
  23. if params.CTimeFrom == "" && params.CTimeTo == "" {
  24. params.CTimeFrom = time.Now().AddDate(0, 0, -7).Format(tformat)
  25. params.CTimeTo = time.Now().Format(tformat)
  26. }
  27. if params.FTimeFrom != "" || params.FTimeTo != "" {
  28. params.State = model.QAStateFinish
  29. }
  30. if params.State != 0 && params.State != model.QAStateFinish {
  31. params.State = model.QAStateWait
  32. }
  33. list, err := srv.GetVideoList(ctx, params)
  34. ctx.JSON(list, err)
  35. }
  36. func detail(ctx *bm.Context) {
  37. idStr := ctx.Request.FormValue("id")
  38. id, err := strconv.ParseInt(idStr, 10, 64)
  39. if err != nil {
  40. ctx.JSON(nil, ecode.RequestErr)
  41. return
  42. }
  43. //任务详情
  44. detail, err := srv.GetDetail(ctx, id)
  45. ctx.JSON(detail, err)
  46. }
  47. func add(ctx *bm.Context) {
  48. //veri params
  49. params := new(model.AddVideoParams)
  50. if err := ctx.BindWith(params, binding.JSON); err != nil {
  51. ctx.JSON(nil, ecode.RequestErr)
  52. return
  53. }
  54. //insert
  55. taskID, err := srv.AddQATaskVideo(ctx, params)
  56. if err != nil {
  57. ctx.JSON(nil, err)
  58. return
  59. }
  60. if taskID <= 0 {
  61. ctx.JSON(nil, ecode.RequestErr)
  62. return
  63. }
  64. ctx.JSON(taskID, nil)
  65. }
  66. func submit(ctx *bm.Context) {
  67. uid, username := getUIDName(ctx)
  68. params := new(model.QASubmitParams)
  69. if err := ctx.Bind(params); err != nil {
  70. ctx.JSON(nil, ecode.RequestErr)
  71. return
  72. }
  73. if _, exist := model.QAAuditStatus[params.AuditStatus]; !exist {
  74. ctx.JSON(nil, ecode.RequestErr)
  75. return
  76. }
  77. if params.AuditStatus == model.VideoStatusRecycle && (params.TagID <= 0 || params.Reason == "") {
  78. ctx.JSON(nil, ecode.RequestErr)
  79. return
  80. }
  81. ctx.JSON(nil, srv.QAVideoSubmit(ctx, username, uid, params))
  82. }
  83. func upTaskUTime(ctx *bm.Context) {
  84. params := new(struct {
  85. TaskID int64 `form:"task_id" validate:"required,gt=0"`
  86. AID int64 `form:"aid" validate:"required,gt=0"`
  87. CID int64 `form:"cid" validate:"required,gt=0"`
  88. UTime int64 `form:"utime"`
  89. })
  90. if err := ctx.Bind(params); err != nil {
  91. log.Error("upTaskUTime ctx.Bind error(%v) params(%+v)", err, ctx.Request.PostForm)
  92. ctx.JSON(nil, ecode.RequestErr)
  93. return
  94. }
  95. ctx.JSON(nil, srv.UpVideoUTime(ctx, params.AID, params.CID, params.TaskID, params.UTime))
  96. }