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

35 lines
880 B
Ruby

#coding=utf-8
module Mobile
module Apis
class Courses < Grape::API
resource :courses do
desc "获取所有课程"
params do
optional :school_id, type: Integer, desc: '传入学校id,返回该学校课程列表'
requires :per_page_count, type: Integer, desc: '每页总数'
requires :page, type: Integer, desc: '当前页码'
end
get do
cs = CoursesService.new
courses = cs.course_list(params)
present :data, courses, with: Mobile::Entities::Course
present :status, 0
end
desc "返回单个课程"
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
end
end
end