Merge branch 'dev_aliyun' of http://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

courseware
cxt 5 years ago
commit 0b1797c6bd

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

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

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

@ -35,7 +35,9 @@ module AliyunVod::Service::VideoManage
}.merge(base_params) }.merge(base_params)
result = request(:post, params) result = request(:post, params)
Rails.logger.info("#######:#{result['Mezzanine']['VideoStreamList'][0]['CodecName']}")
result['Mezzanine']['VideoStreamList'][0]['CodecName'] result['Mezzanine']['VideoStreamList'][0]['CodecName']
rescue => e rescue => e
Rails.logger.info "读取视频编码信息失败: #{video_id}, #{e.message}" Rails.logger.info "读取视频编码信息失败: #{video_id}, #{e.message}"
end end

@ -1,6 +1,13 @@
class Video < ApplicationRecord class Video < ApplicationRecord
include AASM 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' NORMAL_TRANSCODE_GROUP_ID = 'a0277c5c0c7458458e171b0cee6ebf5e'
@ -41,4 +48,17 @@ class Video < ApplicationRecord
def video_play_duration def video_play_duration
(play_duration / (60*60.0)).ceil (play_duration / (60*60.0)).ceil
end 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 end

@ -32,8 +32,10 @@ class Videos::BatchPublishService < ApplicationService
# 标清转码为h264 # 标清转码为h264
if AliyunVod::Service.get_meta_code_info(video.uuid).start_with?('h264', 'h265') if AliyunVod::Service.get_meta_code_info(video.uuid).start_with?('h264', 'h265')
video.transcoded = true video.transcoded = true
result = AliyunVod::Service.get_play_info(video.uuid) #Rails.logger.info("####video.uuid:#{video.uuid}")
video.play_url = result['PlayInfoList']['PlayInfo'][0]['PlayURL'] #result = AliyunVod::Service.get_play_info(video.uuid)
# Rails.logger.info("####video.result:#{result}")
#video.play_url = result['PlayInfoList']['PlayInfo'][0]['PlayURL']
else else
AliyunVod::Service.submit_transcode_job(video.uuid, Video::NORMAL_TRANSCODE_GROUP_ID) AliyunVod::Service.submit_transcode_job(video.uuid, Video::NORMAL_TRANSCODE_GROUP_ID)
end end

@ -18,11 +18,14 @@ class Videos::DispatchCallbackService < ApplicationService
video.save! video.save!
when 'SnapshotComplete' then # 封面截图完成 when 'SnapshotComplete' then # 封面截图完成
return if video.cover_url.present? return if video.cover_url.present?
result = AliyunVod::Service.get_play_info(video.uuid) rescue nil
video.update!(cover_url: params['CoverUrl']) play_url = result['PlayInfoList']['PlayInfo'][0]['PlayURL'] if result
video.update!(cover_url: params['CoverUrl'], play_url: play_url)
when 'StreamTranscodeComplete' then # 转码完成 when 'StreamTranscodeComplete' then # 转码完成
return if video.play_url.present? #return if video.play_url.present?
video.update!(play_url: params['FileUrl'], transcoded: true) video.update!(play_url: params['FileUrl'], transcoded: true)
when 'DeleteMediaComplete' #完成云端视频删除
video.update_column(:delete_state, Video::FINISH_DELETE)
end end
rescue => ex rescue => ex

@ -1,4 +1,4 @@
json.count @count json.count @count
json.videos @videos do |video| json.videos @videos do |video|
json.partial! 'users/videos/video', locals: { video: video.video } json.partial! 'users/videos/video', locals: { video: video }
end 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

@ -191,7 +191,8 @@ function generateNewIndexJsp() {
if (err) { if (err) {
return console.log(err); return console.log(err);
} }
const newVersion = '1.1.1' const newVersion = Date.parse(new Date());
let cdnHost = 'https://shixun.educoder.net' let cdnHost = 'https://shixun.educoder.net'
cdnHost = 'https://ali-cdn.educoder.net' cdnHost = 'https://ali-cdn.educoder.net'
cdnHost = '' cdnHost = ''

@ -101,36 +101,43 @@ class Fileslists extends Component{
} }
} }
componentDidUpdate = (prevProps) => { componentDidUpdate = (prevProps) => {
if(prevProps.match.params.main_id != this.props.match.params.main_id){
this.getcourse_groupslists() if(prevProps.coursesidtype!=this.props.coursesidtype||prevProps.match.params.main_id!=this.props.match.params.main_id||prevProps.match.params.Id!=this.props.match.params.Id){
this.setState({
isSpin:true,
checkBoxValues:[], if(this.props.match.params.main_id){
checkAllValue:false, this.getcourse_groupslists()
}) this.setState({
if(this.props.match.params.main_id!=undefined){ isSpin:true,
this.setState({ checkBoxValues:[],
child:false, checkAllValue:false,
sort:"desc" })
}) if(this.props.match.params.main_id!=undefined){
this.seactall(undefined,"desc"); this.setState({
child:false,
sort:"desc"
})
this.seactall(undefined,"desc");
}
} }
}
if(prevProps.match.params.Id != this.props.match.params.Id){ if(this.props.match.params.Id){
this.getcourse_groupslists() this.getcourse_groupslists()
this.setState({ this.setState({
isSpin:true, isSpin:true,
checkBoxValues:[], checkBoxValues:[],
checkAllValue:false, checkAllValue:false,
}) })
if(this.props.match.params.Id!=undefined){ if(this.props.match.params.Id!=undefined){
this.setState({ this.setState({
child:true, child:true,
sort:"desc" sort:"desc"
}) })
this.seactall(parseInt(this.props.match.params.Id),"desc") this.seactall(parseInt(this.props.match.params.Id),"desc")
}
} }
} }
} }
updadatalist=(id)=>{ updadatalist=(id)=>{
@ -916,7 +923,7 @@ class Fileslists extends Component{
{ {
` `
.filesnameslist{ .filesnameslist{
max-width: 200px; max-width: 370px;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;

@ -53,12 +53,21 @@ class MoveBox extends Component{
video_ids:[id], video_ids:[id],
new_category_id:selectSubId new_category_id:selectSubId
}).then(result=>{ }).then(result=>{
if(result){ if(result){
const { setMoveVisible , successFunc , updataleftNavfun} = this.props; const { setMoveVisible , successFunc , updataleftNavfun} = this.props;
updataleftNavfun && updataleftNavfun(); updataleftNavfun && updataleftNavfun();
setMoveVisible && setMoveVisible(false); setMoveVisible && setMoveVisible(false);
successFunc && successFunc(); successFunc && successFunc();
}
try {
this.props.showNotification(result.data.message);
}catch (e) {
}
}
}).catch(error=>{ }).catch(error=>{
console.log(error); console.log(error);
}) })
@ -69,7 +78,7 @@ class MoveBox extends Component{
const { data , selectSubId } = this.state; const { data , selectSubId } = this.state;
let list = data && data.course_second_categories && data.course_second_categories.length>0?data.course_second_categories:undefined; let list = data && data.course_second_categories && data.course_second_categories.length>0?data.course_second_categories:undefined;
return( return(
<Modal <Modal
visible={visible} visible={visible}
@ -125,4 +134,4 @@ class MoveBox extends Component{
) )
} }
} }
export default MoveBox; export default MoveBox;

@ -295,9 +295,11 @@ function buildColumns(that, student_works, studentData) {
key: 'user_comment_count', key: 'user_comment_count',
dataIndex: 'user_comment_count', dataIndex: 'user_comment_count',
render: (student_score, record) => ( render: (user_comment_count, record) => (
<span style={{color:'#989898', cursor: 'default'}}> <span style={{color:'#989898', cursor: 'default'}}>
{record.user_comment_count} <Tooltip title={"在匿评期间评阅的作品数量"}>
{record.user_comment_count}
</Tooltip>
</span> </span>
), ),
}) })
@ -690,7 +692,7 @@ class CommonWorkList extends Component{
id, user_name, user_login, student_id, group_name, work_status, update_time, teacher_score, teaching_asistant_score, student_score, id, user_name, user_login, student_id, group_name, work_status, update_time, teacher_score, teaching_asistant_score, student_score,
ultimate_score, work_score, student_comment_count, appeal_all_count, appeal_deal_count, ultimate_score, work_score, student_comment_count, appeal_all_count, appeal_deal_count,
late_penalty, absence_penalty, appeal_penalty late_penalty, absence_penalty, appeal_penalty,user_comment_count
, end_immediately, publish_immediately , end_immediately, publish_immediately
, homework_id, visible, work_group, project_info, is_leader , homework_id, visible, work_group, project_info, is_leader
@ -740,7 +742,7 @@ class CommonWorkList extends Component{
}else{ }else{
StudentData=isStudent ? [{ id, user_name, user_login, student_id, group_name, work_status, update_time, teacher_score, teaching_asistant_score, student_score, StudentData=isStudent ? [{ id, user_name, user_login, student_id, group_name, work_status, update_time, teacher_score, teaching_asistant_score, student_score,
ultimate_score, work_score, student_comment_count, appeal_all_count, appeal_deal_count, ultimate_score, work_score, student_comment_count, appeal_all_count, appeal_deal_count,
late_penalty, absence_penalty, appeal_penalty, project_info, is_leader, late_penalty, absence_penalty, appeal_penalty, project_info, is_leader,user_comment_count,
work_group, isMine: true }] : [] work_group, isMine: true }] : []
} }
const columns = buildColumns(this, student_works, StudentData) const columns = buildColumns(this, student_works, StudentData)
@ -773,7 +775,7 @@ class CommonWorkList extends Component{
const hasData = this.state.homework_status && this.state.homework_status.indexOf("未发布") == -1 // student_works && !!student_works.length && page == 1 && const hasData = this.state.homework_status && this.state.homework_status.indexOf("未发布") == -1 // student_works && !!student_works.length && page == 1 &&
// console.log(StudentData) console.log(StudentData)
// console.log(student_works) // console.log(student_works)
return( return(
<React.Fragment> <React.Fragment>

@ -548,7 +548,11 @@ class Coursesleftnav extends Component{
description:result.data.message description:result.data.message
}); });
if(positiontype==="shixun_homeworks"){
this.updasaveNavmoda()
trigger('updateNavSuccess')
this.props.history.push(`/classrooms/${coursesId}/shixun_homework/${result.data.category_id}`);
}
if(positiontype==="files"){ if(positiontype==="files"){
this.updasaveNavmoda() this.updasaveNavmoda()
trigger('updateNavSuccess') trigger('updateNavSuccess')
@ -561,7 +565,7 @@ class Coursesleftnav extends Component{
this.props.history.push(`/classrooms/${coursesId}/boards/${result.data.category_id}`); this.props.history.push(`/classrooms/${coursesId}/boards/${result.data.category_id}`);
} }
if(positiontype!="course_groups"){ if(positiontype!="course_groups"&&positiontype!="shixun_homeworks"){
this.updasaveNavmoda() this.updasaveNavmoda()
} }

@ -146,27 +146,31 @@ class ShixunHomework extends Component{
componentDidUpdate = (prevProps) => { componentDidUpdate = (prevProps) => {
if(prevProps.match.params.main_id != this.props.match.params.main_id){ if(prevProps.coursesidtype!=this.props.coursesidtype||prevProps.match.params.main_id!=this.props.match.params.main_id||prevProps.match.params.category_id!=this.props.match.params.category_id) {
if(this.props.match.params.main_id!=undefined){
this.setState({ if(this.props.match.params.main_id){
checkedtype:false, if(this.props.match.params.main_id!=undefined){
orders:"8", this.setState({
order:undefined, checkedtype:false,
page:1 orders:"8",
}) order:undefined,
this.seactall(); page:1
})
this.seactall();
}
} }
} if(this.props.match.params.category_id){
if(prevProps.match.params.category_id != this.props.match.params.category_id){ if(this.props.match.params.category_id!=undefined){
if(this.props.match.params.category_id!=undefined){ this.setState({
this.setState({ checkedtype:false,
checkedtype:false, orders:"8",
orders:"8", order:undefined,
order:undefined, page:1
page:1 })
}) this.seactall(parseInt(this.props.match.params.category_id))
this.seactall(parseInt(this.props.match.params.category_id)) }
} }
} }
} }

Loading…
Cancel
Save