Merge remote-tracking branch 'origin/dev_aliyun' into dev_aliyun

courseware
杨树明 5 years ago
commit 0dff655be2

@ -132,7 +132,6 @@ class CoursesController < ApplicationController
tip_exception(404, "找不到资源") if video.blank?
tip_exception(403, "...") unless (video.user_id == current_user.id || current_user.admin_or_business?)
video.destroy!
AliyunVod::Service.delete_video([video.uuid]) rescue nil
end
render_ok

@ -26,7 +26,6 @@ class Users::VideosController < Users::BaseController
return render_error('该状态下不能删除视频') unless video.pending?
video.destroy!
AliyunVod::Service.delete_video([video.uuid]) rescue nil
render_ok
end
@ -60,8 +59,6 @@ class Users::VideosController < Users::BaseController
video.destroy!
AliyunVod::Service.delete_video([video.uuid]) rescue nil
render_ok
end

@ -1,4 +1,6 @@
class Weapps::CoursesController < Weapps::BaseController
include CustomSortable
before_action :require_login
before_action :set_course, except: [:create, :check_invite_code]
before_action :user_course_identity, except: [:basic_info, :create, :check_invite_code]

@ -1,6 +1,13 @@
class Video < ApplicationRecord
include AASM
alias_method :hard_destroy, :destroy
default_scope -> { where(delete_state: nil) }
scope :deleted, -> { unscope(where: :delete_state).where.not(delete_state: nil) }
BEGIN_DELETE = 1 # 标记软删除
FINISH_DELETE = 2 # 视频资源完成删除
# 标准视频转码组
NORMAL_TRANSCODE_GROUP_ID = 'a0277c5c0c7458458e171b0cee6ebf5e'
@ -41,4 +48,17 @@ class Video < ApplicationRecord
def video_play_duration
(play_duration / (60*60.0)).ceil
end
def destroy
run_callbacks(:destroy) do
if persisted?
update_column(:delete_state, Video::BEGIN_DELETE)
AliyunVod::Service.delete_video([self.uuid])
end
@destroyed = true
end
freeze
end
end

@ -23,6 +23,8 @@ class Videos::DispatchCallbackService < ApplicationService
when 'StreamTranscodeComplete' then # 转码完成
return if video.play_url.present?
video.update!(play_url: params['FileUrl'], transcoded: true)
when 'DeleteMediaComplete' #完成云端视频删除
video.update_column(:delete_state, Video::FINISH_DELETE)
end
rescue => ex

@ -123,6 +123,7 @@ elsif @homework.homework_type == "group" || @homework.homework_type == "normal"
json.student_works @student_works.each do |work|
if @is_evaluation
json.(work, :id, :work_status, :update_time)
json.user_comment_count @homework_detail_manual.comment_status > 2 && work.work_status > 0 ? work.user_comment_num : 0
json.student_score work_score_format(anon_comments(@current_user, work.id).last.try(:score), false, true)
# json.student_comment_count anon_comments(@current_user, work.id).count

@ -1,4 +1,4 @@
json.count @count
json.videos @videos do |video|
json.partial! 'users/videos/video', locals: { video: video.video }
json.partial! 'users/videos/video', locals: { video: video }
end

@ -0,0 +1,6 @@
class AddDeleteStateToVideo < ActiveRecord::Migration[5.2]
def change
add_column :videos, :delete_state, :integer
add_index :videos, :delete_state
end
end

@ -53,11 +53,20 @@ class MoveBox extends Component{
video_ids:[id],
new_category_id:selectSubId
}).then(result=>{
if(result){
const { setMoveVisible , successFunc , updataleftNavfun} = this.props;
updataleftNavfun && updataleftNavfun();
setMoveVisible && setMoveVisible(false);
successFunc && successFunc();
try {
this.props.showNotification(result.data.message);
}catch (e) {
}
}
}).catch(error=>{
console.log(error);

Loading…
Cancel
Save