From a91d610d6564e3b502bbf6962edb9d37529cf057 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 9 Mar 2020 21:16:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E6=BA=90=E7=9A=84=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 5 +++++ app/views/attachments/_attachment.json.jbuilder | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index c1fa48be8..54b1725f9 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -289,6 +289,11 @@ class FilesController < ApplicationController @old_attachment.save! @new_attachment.delete end + if params[:name].present? && params[:link].present? + tip_exception("资源名称不能超过60个字符") if params[:name].strip.length > 60 + @old_attachment.filename = params[:name].strip + @old_attachment.link = params[:link].strip + end @old_attachment.is_public = is_public == true && @course.is_public == 1 ? 1 : 0 @old_attachment.is_publish = @atta_is_publish @old_attachment.delay_publish = @atta_delay_publish diff --git a/app/views/attachments/_attachment.json.jbuilder b/app/views/attachments/_attachment.json.jbuilder index b30869d57..c87f8372e 100644 --- a/app/views/attachments/_attachment.json.jbuilder +++ b/app/views/attachments/_attachment.json.jbuilder @@ -1,5 +1,6 @@ json.id attachment.id json.title attachment.title +json.link attachment.link json.is_public attachment.publiced? # json.is_lock attachment.locked?(@is_member) json.is_lock !attachment.publiced? @@ -15,4 +16,4 @@ json.created_on attachment.created_on json.content_type attachment.content_type json.is_pdf attachment.is_pdf? json.url attachment.is_pdf? ? download_url(attachment,disposition:"inline") : download_url(attachment) -json.play_url attachment_show_users_path(file_name: local_path(attachment)) +json.play_url attachment.link.present? ? nil : attachment_show_users_path(file_name: local_path(attachment))