From db5e58a911db6961966decde404d0eb129d1f5fc Mon Sep 17 00:00:00 2001 From: p31729568 Date: Tue, 13 Aug 2019 09:22:15 +0800 Subject: [PATCH] modify video batch publish apu --- app/controllers/users/videos_controller.rb | 2 ++ app/services/videos/batch_publish_service.rb | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/app/controllers/users/videos_controller.rb b/app/controllers/users/videos_controller.rb index 03acd76cc..e4dffec23 100644 --- a/app/controllers/users/videos_controller.rb +++ b/app/controllers/users/videos_controller.rb @@ -40,6 +40,8 @@ class Users::VideosController < Users::BaseController def batch_publish Videos::BatchPublishService.call(observed_user, batch_publish_params) render_ok + rescue Videos::BatchPublishService::Error => ex + render_error(ex.message) end private diff --git a/app/services/videos/batch_publish_service.rb b/app/services/videos/batch_publish_service.rb index 3ff16dc57..e435b9508 100644 --- a/app/services/videos/batch_publish_service.rb +++ b/app/services/videos/batch_publish_service.rb @@ -1,4 +1,6 @@ class Videos::BatchPublishService < ApplicationService + Error = Class.new(StandardError) + attr_reader :user, :params def initialize(user, params) @@ -16,6 +18,8 @@ class Videos::BatchPublishService < ApplicationService video = user.videos.find_by(uuid: param[:video_id]) next if video.blank? || video.processing_video_apply.present? + raise Error, '视频还未上传完成' if video.vod_uploading? + video.title = param[:title].to_s.strip.presence || video.title video.apply_publish video.save!