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

35 lines
880 B
Ruby
Raw Normal View History

2014-12-10 18:26:38 +08:00
#coding=utf-8
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
2014-12-10 16:23:56 +08:00
desc "获取所有课程"
2014-12-09 16:36:43 +08:00
params do
2014-12-10 16:23:56 +08:00
optional :school_id, type: Integer, desc: '传入学校id,返回该学校课程列表'
requires :per_page_count, type: Integer, desc: '每页总数'
requires :page, type: Integer, desc: '当前页码'
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-10 16:23:56 +08:00
desc "返回单个课程"
2014-12-09 16:36:43 +08:00
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