socialforge/app/api/mobile/apis/courses.rb

34 lines
812 B
Ruby
Raw Normal View History

2014-11-27 19:43:04 +08:00
module Mobile
module Apis
2014-12-09 16:36:43 +08:00
class Courses < Grape::API
resource :courses do
desc "get all courses"
params do
optional :school_id, type: Integer, desc: 'school number'
requires :per_page_count, type: Integer
requires :page, type: Integer, desc: 'current page no'
2014-12-08 16:51:21 +08:00
end
2014-11-27 19:43:04 +08:00
get do
2014-12-09 16:36:43 +08:00
cs = CoursesService.new
courses = cs.course_list(params)
present :data, courses, with: Mobile::Entities::Course
present :status, 0
2014-11-27 19:43:04 +08:00
end
2014-12-09 16:36:43 +08:00
desc "Return a course"
params do
requires :id, type: Integer
end
route_param :id do
get do
course = Course.find(params[:id])
{status: 0, data: course}
end
end
end
2014-11-27 19:43:04 +08:00
end
end
end