From 8a5f47108ab7881b9e6229b9a00168e14ec3eee6 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 9 Mar 2020 19:35:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E7=9A=84=E5=A4=96=E9=93=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/course_videos_controller.rb | 5 ++++- app/controllers/courses_controller.rb | 17 ++++++++++++----- app/views/courses/course_videos.json.jbuilder | 4 ++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/app/controllers/course_videos_controller.rb b/app/controllers/course_videos_controller.rb index b5915e0ed..0d5a3e460 100644 --- a/app/controllers/course_videos_controller.rb +++ b/app/controllers/course_videos_controller.rb @@ -13,7 +13,10 @@ class CourseVideosController < ApplicationController end def update - + title = params[:name].strip + link = params[:link].strip + @video.update!(title: title, link: link) + render_ok end private diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index e29b177d6..4a40c84b3 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -116,11 +116,18 @@ class CoursesController < ApplicationController end def delete_course_video - video = Video.find_by(id: params[:video_id]) - 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 + if params[:is_link] + video = @course.course_videos.find_by!(id: params[:video_id]) + tip_exception(403, "...") unless (video.user_id == current_user.id || current_user.admin_or_business?) + video.destroy! + else + video = Video.find_by(id: params[:video_id]) + 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 end diff --git a/app/views/courses/course_videos.json.jbuilder b/app/views/courses/course_videos.json.jbuilder index 627b0d6e9..bee5e89cb 100644 --- a/app/views/courses/course_videos.json.jbuilder +++ b/app/views/courses/course_videos.json.jbuilder @@ -1,7 +1,6 @@ json.count @count json.videos @videos do |video| - Rails.logger.info("video@############{video.id}, #{video.is_link}") if video.is_link json.(video, :id, :title, :link, :user_id) @@ -19,4 +18,5 @@ if @category.present? json.category_id @category.id json.category_name @category.name end -json.course_module_id @video_module&.id \ No newline at end of file +json.course_module_id @video_module&.id +json.has_category @video_module.course_second_categories.size > 0 \ No newline at end of file