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

41 lines
1.2 KiB
Ruby
Raw Normal View History

2016-03-30 17:47:44 +08:00
#coding=utf-8
module Mobile
module Apis
class Whomeworks< Grape::API
resources :whomeworks do
desc "get one homework"
2016-07-20 13:34:58 +08:00
post ':id' do
begin
# authenticate!
user = current_user
2016-07-20 13:34:58 +08:00
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
2016-08-09 17:01:06 +08:00
is_public = 1
if type == 0
homework = HomeworkCommon.find params[:id]
2016-08-09 17:01:06 +08:00
is_public = homework.course.is_public
present :data, homework, with: Mobile::Entities::Whomework,user: user,type: type,page: page,comment_type: "homework"
else
jour = JournalsForMessage.find params[:id]
present :data, jour, with: Mobile::Entities::Jours,user: user,type: type,page: page,comment_type: "homework"
end
present :type, type
present :page, page
2016-08-09 17:01:06 +08:00
present :is_public, is_public
present :status, 0
rescue Exception=>e
present :status, -1
present :message, e.message
end
2016-03-30 17:47:44 +08:00
end
end
end
end
end