diff --git a/app/api/mobile/apis/comments.rb b/app/api/mobile/apis/comments.rb index a7eea735d..7a7f17d8f 100644 --- a/app/api/mobile/apis/comments.rb +++ b/app/api/mobile/apis/comments.rb @@ -72,6 +72,20 @@ module Mobile present :status, 0 end + desc ' 意见反馈' + params do + requires :token, type: String + requires :subject,type: String,desc: '意见' + end + post do + cs_params = { + memo: {:subject => params[:subject],:content => '该贴来自手机App意见反馈'}, + } + cs = CommentService.new + memo = cs.create_feedback cs_params, current_user + raise "commit failed #{memo.errors.full_messages}" if memo.new_record? + present :status, 0 + end end end diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index 54b8c6305..2f7092d9a 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -15,12 +15,14 @@ class ForumsController < ApplicationController PageLimit = 20 def create_feedback if User.current.logged? - @memo = Memo.new(params[:memo]) - @memo.forum_id = "1" - @memo.author_id = User.current.id + #@memo = Memo.new(params[:memo]) + #@memo.forum_id = "1" + #@memo.author_id = User.current.id #@forum = @memo.forum + cs = CommentService.new + @memo = cs.create_feedback params,User.current respond_to do |format| - if @memo.save + if !@memo.new_record? format.html { redirect_to forum_path(@memo.forum) } else sort_init 'updated_at', 'desc' diff --git a/app/services/comment_service.rb b/app/services/comment_service.rb index 42dc8c415..876caaaf3 100644 --- a/app/services/comment_service.rb +++ b/app/services/comment_service.rb @@ -78,4 +78,13 @@ class CommentService @jfm end + #发贴,用于意见反馈 + def create_feedback params,current_user + @memo = Memo.new(params[:memo]) + @memo.forum_id = "1" + @memo.author_id = current_user.id + @memo.save + @memo + end + end \ No newline at end of file