2015-02-04 11:57:37 +08:00
|
|
|
#coding=utf-8
|
|
|
|
module Mobile
|
|
|
|
module Apis
|
|
|
|
class Comments < Grape::API
|
|
|
|
resource :comments do
|
|
|
|
desc '课程通知评论'
|
|
|
|
params do
|
|
|
|
requires :token, type: String
|
2015-02-04 14:39:46 +08:00
|
|
|
requires :comments, type: String
|
2015-02-04 11:57:37 +08:00
|
|
|
end
|
|
|
|
post ':id' do
|
|
|
|
cs = CommentService.new
|
2015-02-04 14:39:46 +08:00
|
|
|
cs_params = {
|
|
|
|
id: params[:id],
|
|
|
|
comment: params.reject{|k,v| [:id].include?(k)}}
|
|
|
|
comments = cs.news_comments cs_params,current_user
|
2015-02-04 11:57:37 +08:00
|
|
|
raise "create comments failed #{comments.errors.full_messages}" if comments.new_record?
|
|
|
|
present :data, comments, with: Mobile::Entities::Comment
|
|
|
|
present :status, 0
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|