diff --git a/app/api/mobile/apis/new_comment.rb b/app/api/mobile/apis/new_comment.rb index 753299956..2c3cb3f82 100644 --- a/app/api/mobile/apis/new_comment.rb +++ b/app/api/mobile/apis/new_comment.rb @@ -12,7 +12,7 @@ module Mobile requires :type, type: String requires :content, type: String end - post ':id' do + get ':id' do type = params[:type] result = 1 current_user = User.find 8686 @@ -75,12 +75,12 @@ module Mobile end when 'Issue' issue = Issue.find params[:id] - jour = Journal.new - jour.user_id = current_user.id - jour.notes = params[:content] - jour.journalized_id = params[:id] - jour.journalized_type = "Issue" - if jour.save + is_jour = Journal.new + is_jour.user_id = current_user.id + is_jour.notes = params[:content] + is_jour.journalized = issue + #is_jour.journalized_type = "Issue" + if issue.journals << is_jour result = 2 else result = 3 diff --git a/app/api/mobile/entities/journal.rb b/app/api/mobile/entities/journal.rb index 6eb254a6b..83dbb9e00 100644 --- a/app/api/mobile/entities/journal.rb +++ b/app/api/mobile/entities/journal.rb @@ -34,6 +34,10 @@ module Entities expose :notes journal_expose :created_on + journal_expose :last_created_time + expose :user,using: Mobile::Entities::User do |f, opt| + f.user + end #journal_expose :detail_journal end end diff --git a/app/models/journal.rb b/app/models/journal.rb index 49fb0aa35..ed76c65a7 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -238,7 +238,6 @@ class Journal < ActiveRecord::Base #缺陷回复微信模板消息 def issue_wechat_message - unless self.parent_id == nil uw = UserWechat.where(user_id: self.issue.author_id).first #unless uw.nil? && self.issue.author_id != User.current.id unless uw.nil? @@ -279,6 +278,5 @@ class Journal < ActiveRecord::Base client.request(request) end end - end end end diff --git a/public/javascripts/wechat/homework-detail.js b/public/javascripts/wechat/homework-detail.js index 1c223bfc2..92796cf3f 100644 --- a/public/javascripts/wechat/homework-detail.js +++ b/public/javascripts/wechat/homework-detail.js @@ -74,7 +74,7 @@ $(document).ready(function(){ url: apiUrl + 'new_comment/' + homeworkID, //提交的页面,方法名 data: userInfo, //参数,如果没有,可以为null success: function (data) { //如果执行成功,那么执行此方法 - alert(data.d); //用data.d来获取后台传过来的json语句,或者是单纯的语句 + alert(data.result); //用data.d来获取后台传过来的json语句,或者是单纯的语句 }, error: function (err) { //如果执行不成功,那么执行此方法 alert("err:" + err);