You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trustieforge/app/api/mobile/apis/resources.rb

75 lines
1.7 KiB

#coding=utf-8
module Mobile
module Apis
class Resources < Grape::API
resource :resources do
desc '获取所有课件'
params do
requires :token, type: String
end
get do
authenticate!
rs = ResourcesService.new
# data = current_user.course_attachments
data = rs.all_course_attachments current_user
present :data, data, with: Mobile::Entities::Attachment
present :status, 0
end
desc '获取所有作业'
params do
requires :token, type: String
end
get 'homeworks' do
authenticate!
rs = ResourcesService.new
homeworks = rs.all_homework_commons current_user
present :data, homeworks, with: Mobile::Entities::Homework
present :status, 0
end
desc '获取所有测验'
params do
requires :token, type: String
end
get 'exercies' do
authenticate!
rs = ResourcesService.new
exercises = rs.all_exercises current_user
present :data, exercises, with: Mobile::Entities::Exercise
present :status, 0
end
desc '发送资源'
params do
requires :token, type: String
requires :course_ids, type: Array[Integer]
requires :send_id, type: Integer
end
post 'send' do
authenticate!
rs = ResourcesService.new
ori, flag, save_message = rs.send_resource_to_course(current_user,params)
if flag
present :status, 0
else
{status: -1, message: save_message.first}
end
end
end
end
end
end