diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index f23be51d5..7a4130bce 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -25,7 +25,7 @@ class CoursesController < ApplicationController :delete_course_teacher, :teacher_application_review, :students, :all_course_groups, :transfer_to_course_group, :delete_from_course, :search_users, :add_students_by_search, :base_info, :get_historical_courses, :create_group_by_importing_file, :course_videos, - :attahcment_category_list,:export_member_scores_excel, :duplicate_course, + :attahcment_category_list,:export_member_scores_excel, :duplicate_course, :delete_course_video, :switch_to_teacher, :switch_to_assistant, :switch_to_student, :exit_course, :informs, :update_informs, :online_learning, :update_task_position, :tasks_list, :join_excellent_course, :export_couser_info, :export_member_act_score, :new_informs, @@ -109,6 +109,15 @@ class CoursesController < ApplicationController @videos = paginate videos end + def delete_course_video + video = Video.find_by(uuid: params[:video_id]) + tip_exception(404, "找不到资源") if video.blank? + tip_exception(403, "...") if video.user_id != current_user.id || !current_user.admin_or_business? + video.destroy! + AliyunVod::Service.delete_video([video.uuid]) rescue nil + render_ok + end + def visits_plus_one new_visits = @course.visits + 1 @course.update_visits(new_visits) diff --git a/config/routes.rb b/config/routes.rb index 63a6e4494..971c1859f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -516,6 +516,7 @@ Rails.application.routes.draw do get 'act_score' get 'statistics' get 'course_videos' + delete 'delete_course_video' post :inform_up post :inform_down get :calculate_all_shixun_scores