修正作业留言接口

This commit is contained in:
z9hang 2015-02-05 16:11:35 +08:00
parent d6813e5996
commit ef203ff40c
3 changed files with 11 additions and 7 deletions

View File

@ -22,19 +22,20 @@ module Mobile
desc '作业留言(教师布置的作业)' desc '作业留言(教师布置的作业)'
params do params do
requires :token, type: String requires :token, type: String
requires :id, type: Integer,desc: '老师布置的作业id' #requires :id, type: Integer,desc: '老师布置的作业id'
requires :message,type: String, desc: '留言' requires :message,type: String, desc: '留言'
optional :reference_content, type: String ,desc: '引用的内容' #optional :reference_content, type: String ,desc: '引用的内容'
optional :reference_user_id, type: Integer,desc: '被引用的人' #optional :reference_user_id, type: Integer,desc: '被引用的人'
end end
post 'create_homework_message' do post ':id/create_homework_message' do
cs_params = { cs_params = {
id: params[:id], id: params[:id],
token: params[:token], token: params[:token],
reference_content: params[:reference_content], reference_content: params[:reference_content],
bid_message: params.reject{|k,v| [:id,:token,:reference_content].include?(k)}} bid_message: params.reject{|k,v| [:id,:token,:reference_content].include?(k)}}
cs = CommentService.new 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 present :status, 0
end end

View File

@ -93,7 +93,9 @@ class Bid < ActiveRecord::Base
# 'deadline' # 'deadline'
def add_jour(user, notes, reference_user_id = 0, options = {}) def add_jour(user, notes, reference_user_id = 0, options = {})
if options.count == 0 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 else
jfm = self.journals_for_messages.build(options) jfm = self.journals_for_messages.build(options)
jfm.save jfm.save

View File

@ -28,12 +28,13 @@ class CommentService
@m = message @m = message
end end
refer_user_id = params[:bid_message][:reference_user_id].to_i 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 end
#@user = @bid.author #@user = @bid.author
#@jours = @bid.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') #@jours = @bid.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
#@jour = paginateHelper @jours,10 #@jour = paginateHelper @jours,10
@bid.set_commit(@feedback_count) @bid.set_commit(@feedback_count)
jfm
end end
end end