From cc83b30fc6c230a54182cf4a3c0979f69210db4d Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 6 Feb 2015 14:29:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=90=9C=E7=B4=A2=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=8E=A5=E5=8F=A3=EF=BC=8C=E6=B7=BB=E5=8A=A0=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E5=8A=A8=E6=80=81=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/courses.rb | 10 ++++++++++ app/api/mobile/apis/users.rb | 18 ++++++++++-------- app/services/courses_service.rb | 8 ++++++++ 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index 8f8c08c3f..7b3fc7cd5 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -209,6 +209,16 @@ module Mobile present :status, 0 end + desc '课程动态' + params do + requires :token, type: String + end + get "course_dynamic/:id" do + cs = CoursesService.new + count = cs.course_dynamic(params,current_user) + present :data, count + present :status, 0 + end end end diff --git a/app/api/mobile/apis/users.rb b/app/api/mobile/apis/users.rb index 69260716e..d780b9db4 100644 --- a/app/api/mobile/apis/users.rb +++ b/app/api/mobile/apis/users.rb @@ -22,13 +22,15 @@ module Mobile desc "显示用户" params do - + requires :id, type: Integer end - get ':id' do - us = UsersService.new - ue = us.show_user params - present :data, ue,with: Mobile::Entities::User - present :status, 0 + route_param :id do + get do + us = UsersService.new + ue = us.show_user params + present :data, ue,with: Mobile::Entities::User + present :status, 0 + end end desc "修改用户" @@ -77,11 +79,11 @@ module Mobile present :status, 0 end - desc "用户搜索" + desc "用户搜索" params do requires :name, type: String, desc: '用户名关键字' end - get 'search' do + get 'search/search_user' do us = UsersService.new user = us.search_user params present :data, user, with: Mobile::Entities::User diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 341ecd422..d987514c2 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -2,6 +2,7 @@ class CoursesService include ApplicationHelper include CoursesHelper include HomeworkAttachHelper + include ApiHelper #TODO:尚未整合权限系统 #参数school_id为0或不传时返回所有课程,否则返回对应学校的课程 #参数per_page_count分页功能,每页显示的课程数 @@ -326,6 +327,11 @@ class CoursesService end end + def course_dynamic params,current_user + count = get_course_anonymous_evaluation current_user,params[:id] + count + end + private def show_homework_info course,bid,current_user,is_course_teacher author = bid.author.lastname + bid.author.firstname @@ -361,4 +367,6 @@ class CoursesService :description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation} end + + end \ No newline at end of file