45 lines
1.2 KiB
Ruby
45 lines
1.2 KiB
Ruby
#coding=utf-8
|
|
|
|
module Mobile
|
|
module Apis
|
|
class Messages< Grape::API
|
|
resources :messages do
|
|
|
|
desc "get special topic"
|
|
post ':id' do
|
|
begin
|
|
# authenticate!
|
|
user = current_user
|
|
|
|
#0一级回复的更多 1 二级回复的更多
|
|
type = params[:type] || 0
|
|
page = params[:page] || 0
|
|
message = Message.find params[:id]
|
|
|
|
is_public = 1
|
|
type_name = ""
|
|
|
|
if message.project
|
|
is_public = message.project.is_public
|
|
type_name = "project"
|
|
elsif message.course
|
|
is_public = message.course.is_public
|
|
type_name = "course"
|
|
end
|
|
|
|
present :data, message, with: Mobile::Entities::Message,user: user,type: type,page: page
|
|
present :type, type
|
|
present :page, page
|
|
present :is_public, is_public
|
|
present :type_name, type_name
|
|
present :status, 0
|
|
rescue Exception=>e
|
|
present :status, -1
|
|
present :message, e.message
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|