From 5c648c9284a709a2d7c02aa877101648d592c14a Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 3 Jul 2015 15:32:57 +0800 Subject: [PATCH] =?UTF-8?q?Attachment=E6=B7=BB=E5=8A=A0file=5Fdir=20?= =?UTF-8?q?=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/entities/attachment.rb | 8 +++++--- app/services/courses_service.rb | 19 +++++-------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/app/api/mobile/entities/attachment.rb b/app/api/mobile/entities/attachment.rb index b7424fac9..bb67b6d28 100644 --- a/app/api/mobile/entities/attachment.rb +++ b/app/api/mobile/entities/attachment.rb @@ -14,9 +14,10 @@ module Mobile f.send(field) end else - #case field - # when "" - #end + case field + when :file_dir + "attachments/download/" << f.send(:id).to_s << '/' + end end end end @@ -27,6 +28,7 @@ module Mobile attachment_expose :downloads attachment_expose :quotes attachment_expose :created_on + attachment_expose :file_dir end end end \ No newline at end of file diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 81cf339dd..7efe76b3a 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -434,24 +434,15 @@ class CoursesService # 课程课件 def course_attachments params result = [] - @course = Course.find(params[:course_id]) - @attachments = @course.attachments.order("created_on desc") + course = Course.find(params[:course_id]) + attachments = course.attachments.order("created_on ") if !params[:name].nil? && params[:name] != "" - @attachments.each do |atta| - result << {:filename => atta.filename, - :description => atta.description, - :downloads => atta.downloads, - :quotes => atta.quotes.nil? ? 0 :atta.quotes } if atta.filename.include?(params[:name]) + attachments.each do |atta| + result << atta if atta.filename.include?(params[:name]) end else - @attachments.each do |atta| - result << {:filename => atta.filename, - :description => atta.description, - :downloads => atta.downloads, - :quotes => atta.quotes.nil? ? 0 :atta.quotes } - - end + result = attachments end result end