From a9d76e6f5162d575ed3ad218861fec5a74fd2d71 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 12 Feb 2020 11:06:27 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E8=A7=86=E9=A2=91=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 11 ++++++++++- config/routes.rb | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) 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 From 4798bf9beb58e29ab2b860241de9c9120c549a90 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 12 Feb 2020 11:16:19 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E8=A7=86=E9=A2=91=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 7a4130bce..85f918921 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -110,9 +110,9 @@ class CoursesController < ApplicationController end def delete_course_video - video = Video.find_by(uuid: params[:video_id]) + video = Video.find_by(id: params[:video_id]) tip_exception(404, "找不到资源") if video.blank? - tip_exception(403, "...") if video.user_id != current_user.id || !current_user.admin_or_business? + 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 From 029e460ee33ef558c19fe90ca71b0badab1e350a Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 12 Feb 2020 11:17:57 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E8=A7=86=E9=A2=91=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 85f918921..d737ed126 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -112,7 +112,7 @@ class CoursesController < ApplicationController def delete_course_video video = Video.find_by(id: params[:video_id]) tip_exception(404, "找不到资源") if video.blank? - tip_exception(403, "...") if (video.user_id == current_user.id || current_user.admin_or_business?) + 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 render_ok From e6e4c346bafe3b3566e51e609dd773ab7f7ed293 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 12 Feb 2020 11:31:30 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/videos/_video.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/videos/_video.json.jbuilder b/app/views/users/videos/_video.json.jbuilder index e28363a34..1e09ca4b9 100644 --- a/app/views/users/videos/_video.json.jbuilder +++ b/app/views/users/videos/_video.json.jbuilder @@ -1,4 +1,4 @@ -json.extract! video, :id, :title, :cover_url, :file_url, :play_url, :vv +json.extract! video, :id, :title, :cover_url, :file_url, :play_url, :vv, :user_id json.play_duration video.video_play_duration json.published_at video.display_published_at From d40022b1486a78d0ca315f92eb72f2ed3a66c520 Mon Sep 17 00:00:00 2001 From: caicai8 <1149225589@qq.com> Date: Wed, 12 Feb 2020 14:02:15 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E8=A7=86=E9=A2=91=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../react/src/modules/courses/Video/Video.js | 37 +++++++++++++++++-- .../src/modules/courses/Video/VideoIndex.js | 10 +++++ .../user/usersInfo/video/InfosVideo.css | 2 +- .../user/usersInfo/video/VideoInReviewItem.js | 11 +++++- 4 files changed, 54 insertions(+), 6 deletions(-) diff --git a/public/react/src/modules/courses/Video/Video.js b/public/react/src/modules/courses/Video/Video.js index e15ddf6d4..d92d7addc 100644 --- a/public/react/src/modules/courses/Video/Video.js +++ b/public/react/src/modules/courses/Video/Video.js @@ -10,6 +10,7 @@ import ClipboardJS from 'clipboard' import './video.css'; import '../../user/usersInfo/video/InfosVideo.css' +import axios from 'axios'; const DEFAULT_VIDEO_WIDTH_IN_MD = "90%" // 400 const DEFAULT_VIDEO_HEIGHT_IN_MD = "55%" // 400 @@ -17,7 +18,6 @@ const DEFAULT_VIDEO_HEIGHT_IN_MD = "55%" // 400 const videoEl = null; let _clipboard = null; - class Video extends Component{ constructor(props){ super(props); @@ -69,9 +69,8 @@ class Video extends Component{ // 编辑成功后回调的方法 editSuccess=()=>{ - const { page } = this.state; this.props.showNotification("视频名称修改成功!"); - const { listFunc } = this.props; + const { listFunc , page } = this.props; listFunc && listFunc(page); } @@ -132,13 +131,42 @@ class Video extends Component{ return `` } + // 删除事件 + deleteVideo=(item)=>{ + this.props.confirm({ + content: '该视频将被删除,不可恢复', + subContent:'是否确认删除?', + + onOk: () => { + const CourseId=this.props.match.params.coursesId; + const url = `/courses/${CourseId}/delete_course_video.json`; + axios.delete(url,{ + params:{ + video_id:item.id + } + }).then(result=>{ + if(result){ + this.props.showNotification(`删除成功!`); + const { listFunc , page } = this.props; + listFunc && listFunc(page); + } + }).catch(error=>{ + console.log(error); + }) + }, + onCancel() { + console.log('Cancel'); + }, + }); + } + render(){ const { visible , videoVisible , videoId } = this.state; const CourseId=this.props.match.params.coursesId; const login=this.props.user&&this.props.user.login; const _inputValue = videoId && this.getCopyText(videoId.file_url, videoId.cover_url); - const { admin , is_teacher ,business} = this.props.user; + const { admin , is_teacher ,business , user_id} = this.props.user; const { videos , upload , uploadVideo , videoData , changePage ,pageSize ,page } = this.props; @@ -195,6 +223,7 @@ class Video extends Component{ onMaskClick={this.onMaskClick} getCopyText={this.getCopyText} operation={operation} + deleteVideo={(admin || item.user_id === user_id) ? this.deleteVideo : undefined} > ) diff --git a/public/react/src/modules/courses/Video/VideoIndex.js b/public/react/src/modules/courses/Video/VideoIndex.js index 774f35de9..ec1c0d4f5 100644 --- a/public/react/src/modules/courses/Video/VideoIndex.js +++ b/public/react/src/modules/courses/Video/VideoIndex.js @@ -189,6 +189,16 @@ class VideoIndex extends Component{ {...this.props} {...this.state} > + { + liveVisible ? + :"" + }