#coding=utf-8 module Mobile module Apis class Comments < Grape::API resource :comments do desc '课程通知评论' params do requires :token, type: String requires :comments, type: String end post ':id' do cs = CommentService.new cs_params = { id: params[:id], comment: params.reject{|k,v| [:id].include?(k)}} comments = cs.news_comments cs_params,current_user raise "create comments failed #{comments.errors.full_messages}" if comments.new_record? present :data, comments, with: Mobile::Entities::Comment present :status, 0 end desc '作业留言(教师布置的作业)' params do requires :token, type: String requires :id, type: Integer,desc: '老师布置的作业id' requires :message,type: String, desc: '留言' optional :reference_content, type: String ,desc: '引用的内容' optional :reference_user_id, type: Integer,desc: '被引用的人' end post 'create_homework_message' do cs_params = { id: params[:id], token: params[:token], reference_content: params[:reference_content], bid_message: params.reject{|k,v| [:id,:token,:reference_content].include?(k)}} cs = CommentService.new cs.homework_message cs_params,current_user present :status, 0 end end end end end