|
|
|
@ -7,7 +7,7 @@ class FilesController < ApplicationController
|
|
|
|
|
before_action :file_validate_sort_type, only: :index
|
|
|
|
|
before_action :validate_send_message_to_course_params, only: :bulk_send
|
|
|
|
|
before_action :set_pagination, only: %i[index public_with_course_and_project mine_with_course_and_project]
|
|
|
|
|
before_action :validate_upload_params, only: %i[upload import]
|
|
|
|
|
before_action :validate_upload_params, only: %i[import]
|
|
|
|
|
before_action :find_file, only: %i[show setting update]
|
|
|
|
|
before_action :publish_params, only: %i[upload import update]
|
|
|
|
|
|
|
|
|
@ -163,6 +163,7 @@ class FilesController < ApplicationController
|
|
|
|
|
|
|
|
|
|
# 上传资源
|
|
|
|
|
def upload
|
|
|
|
|
find_course_second_category_id
|
|
|
|
|
attachment_ids = params[:attachment_ids]
|
|
|
|
|
course_second_category_id = params[:course_second_category_id] || 0 # 0: 为主目录, 其他为次目录id
|
|
|
|
|
# is_unified_setting = params.has_key?(:is_unified_setting) ? params[:is_unified_setting] : true
|
|
|
|
@ -170,6 +171,7 @@ class FilesController < ApplicationController
|
|
|
|
|
# course_group_publish_times = params[:course_group_publish_times] || []
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
if attachment_ids.present?
|
|
|
|
|
attachment_ids.each do |attchment_id|
|
|
|
|
|
attachment = Attachment.find_by_id attchment_id
|
|
|
|
|
unless attachment.nil?
|
|
|
|
@ -189,6 +191,28 @@ class FilesController < ApplicationController
|
|
|
|
|
attachment.save!
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
tip_exception("资源名称不能为空") if params[:name].blank?
|
|
|
|
|
tip_exception("资源名称不能超过60个字符") if params[:name].strip.length > 60
|
|
|
|
|
tip_exception("链接地址不能为空") if params[:link].blank?
|
|
|
|
|
attachment = Attachment.new
|
|
|
|
|
attachment.container = @course
|
|
|
|
|
attachment.course_second_category_id = course_second_category_id
|
|
|
|
|
attachment.author_id = current_user.id
|
|
|
|
|
attachment.filename = params[:name].strip
|
|
|
|
|
attachment.link = params[:link].strip
|
|
|
|
|
attachment.description = params[:description]
|
|
|
|
|
attachment.is_public = params[:is_public] && @course.is_public == 1 ? 1 : 0
|
|
|
|
|
attachment.is_publish = @atta_is_publish
|
|
|
|
|
attachment.delay_publish = @atta_delay_publish
|
|
|
|
|
attachment.publish_time = @atta_publish_time
|
|
|
|
|
attachment.unified_setting = @unified_setting
|
|
|
|
|
if @unified_setting == 0
|
|
|
|
|
attachment_group_setting attachment, params[:group_settings]
|
|
|
|
|
end
|
|
|
|
|
attachment.save!
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
uid_logger_error(e.message)
|
|
|
|
|
tip_exception(e.message)
|
|
|
|
|