|
|
|
@ -11,26 +11,35 @@ class Videos::BatchPublishService < ApplicationService
|
|
|
|
|
def call
|
|
|
|
|
video_params = Array.wrap(params[:videos]).compact
|
|
|
|
|
return if video_params.blank?
|
|
|
|
|
Rails.logger.info("#####video_course: #{video_params}")
|
|
|
|
|
|
|
|
|
|
video_ids = []
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
video_params.each do |param|
|
|
|
|
|
video = user.videos.find_by(uuid: param[:video_id])
|
|
|
|
|
Rails.logger.info("video.processing_video_apply:#{video}")
|
|
|
|
|
Rails.logger.info("video.processing_video_apply:#{video.blank? || video.processing_video_apply}")
|
|
|
|
|
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!
|
|
|
|
|
|
|
|
|
|
video.video_applies.create!
|
|
|
|
|
if param[:course_id].present?
|
|
|
|
|
video.video_applies.create!(status: "agreed")
|
|
|
|
|
else
|
|
|
|
|
video.video_applies.create!
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
video_ids << video.id
|
|
|
|
|
|
|
|
|
|
# 如果是课堂上传则创建课堂记录
|
|
|
|
|
if params[:course_id].present?
|
|
|
|
|
video.course_videos.create!(course_id: params[:course_id])
|
|
|
|
|
Rails.logger.info("#####param: #{ param[:course_id]}")
|
|
|
|
|
if param[:course_id].present?
|
|
|
|
|
video.course_videos.create!(course_id: param[:course_id])
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|