添加显示课程的课件列表

memcached_alan
lizanle 10 years ago
parent ee0ef7dc69
commit 519eab76bd

@ -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

@ -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

@ -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

Loading…
Cancel
Save