From 519eab76bdbe130996f1e6e9d15e6df0eca0a21e Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Wed, 29 Apr 2015 17:46:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=98=BE=E7=A4=BA=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E7=9A=84=E8=AF=BE=E4=BB=B6=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/courses.rb | 12 ++++++++++++ app/api/mobile/entities/attachment.rb | 3 +++ app/services/courses_service.rb | 11 +++++++++++ 3 files changed, 26 insertions(+) diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index 08c7adf10..ce02f4249 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -228,6 +228,18 @@ module Mobile present :status, 0 end + desc '课程课件' + params do + requires :token, type: String + requires :course_id,type: Integer,desc: '课程id' + end + get ":course_id/attachments" do + cs = CoursesService.new + count = cs.course_attachments params + present :data, count, with: Mobile::Entities::Attachment + present :status, 0 + end + end end end diff --git a/app/api/mobile/entities/attachment.rb b/app/api/mobile/entities/attachment.rb index 510db89be..080b24558 100644 --- a/app/api/mobile/entities/attachment.rb +++ b/app/api/mobile/entities/attachment.rb @@ -16,8 +16,11 @@ module Mobile end end end + attachment_expose :id attachment_expose :filename attachment_expose :description + attachment_expose :downloads + attachment_expose :quotes end end end \ No newline at end of file diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index e91883bee..b992665d3 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -428,6 +428,17 @@ class CoursesService result end + # 课程课件 + def course_attachments params + result = [] + @course = Course.find(params[:course_id]) + @attachments = @course.attachments.order("created_on desc") + @attachments.each do |atta| + result << {:filename => atta.filename,:description => atta.description,:downloads => atta.downloads,:quotes => atta.quotes.nil? ? 0 :atta.quotes } + end + result + end + private def show_homework_info course,bid,current_user,is_course_teacher author_real_name = bid.author.lastname + bid.author.firstname