From ef203ff40c0bf8250bbf3a084c733e2970a18424 Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 5 Feb 2015 16:11:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=BD=9C=E4=B8=9A=E7=95=99?= =?UTF-8?q?=E8=A8=80=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/comments.rb | 11 ++++++----- app/models/bid.rb | 4 +++- app/services/comment_service.rb | 3 ++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/api/mobile/apis/comments.rb b/app/api/mobile/apis/comments.rb index fb30f59f4..c6d925868 100644 --- a/app/api/mobile/apis/comments.rb +++ b/app/api/mobile/apis/comments.rb @@ -22,19 +22,20 @@ module Mobile desc '作业留言(教师布置的作业)' params do requires :token, type: String - requires :id, type: Integer,desc: '老师布置的作业id' + #requires :id, type: Integer,desc: '老师布置的作业id' requires :message,type: String, desc: '留言' - optional :reference_content, type: String ,desc: '引用的内容' - optional :reference_user_id, type: Integer,desc: '被引用的人' + #optional :reference_content, type: String ,desc: '引用的内容' + #optional :reference_user_id, type: Integer,desc: '被引用的人' end - post 'create_homework_message' do + post ':id/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 + message = cs.homework_message cs_params,current_user + present :data, message, with: Mobile::Entities::Jours present :status, 0 end diff --git a/app/models/bid.rb b/app/models/bid.rb index f423266b8..eb7e5d83f 100644 --- a/app/models/bid.rb +++ b/app/models/bid.rb @@ -93,7 +93,9 @@ class Bid < ActiveRecord::Base # 'deadline' def add_jour(user, notes, reference_user_id = 0, options = {}) if options.count == 0 - self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id) + jfm = JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id) + self.journals_for_messages << jfm + jfm else jfm = self.journals_for_messages.build(options) jfm.save diff --git a/app/services/comment_service.rb b/app/services/comment_service.rb index 84a7d09cf..5d40bf6bc 100644 --- a/app/services/comment_service.rb +++ b/app/services/comment_service.rb @@ -28,12 +28,13 @@ class CommentService @m = message end refer_user_id = params[:bid_message][:reference_user_id].to_i - @bid.add_jour(current_user, message, refer_user_id) + jfm = @bid.add_jour(current_user, message, refer_user_id) end #@user = @bid.author #@jours = @bid.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') #@jour = paginateHelper @jours,10 @bid.set_commit(@feedback_count) + jfm end end \ No newline at end of file