From 5a3d324ce49bb1c384259be9948f3313b1088509 Mon Sep 17 00:00:00 2001 From: z9hang Date: Sat, 7 Mar 2015 16:19:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AF=BE=E7=A8=8B=E7=95=99?= =?UTF-8?q?=E8=A8=80=E5=88=97=E8=A1=A8=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/services/comment_service.rb | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/app/api/mobile/apis/comments.rb b/app/api/mobile/apis/comments.rb index 7a7f17d8f..75932d60f 100644 --- a/app/api/mobile/apis/comments.rb +++ b/app/api/mobile/apis/comments.rb @@ -87,6 +87,17 @@ module Mobile present :status, 0 end + desc '课程留言列表' + params do + optional :token, type: String + end + get ':id/course_message' do + cs = CommentService.new + jours = cs.course_messages params,(current_user.nil? ? User.find(2):current_user) + present :data, jours, with: Mobile::Entities::Jours + present :status, 0 + end + end end end diff --git a/app/services/comment_service.rb b/app/services/comment_service.rb index 876caaaf3..e74cc902b 100644 --- a/app/services/comment_service.rb +++ b/app/services/comment_service.rb @@ -87,4 +87,15 @@ class CommentService @memo end + #课程留言列表 + def course_messages params,current_user + @course = ::Course.find(params[:id]) + if (current_user.admin? || @course.is_public == 1 || (@course.is_public == 0 && current_user.member_of_course?(@course))) + @jours = @course.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') + else + raise '403' + end + @jours + end + end \ No newline at end of file