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