修复课程教师,课程学生接口

This commit is contained in:
z9hang 2015-01-07 15:24:43 +08:00
parent 303752fc7e
commit fdb38c1b87
2 changed files with 39 additions and 6 deletions

View File

@ -140,22 +140,26 @@ module Mobile
desc "课程老师列表"
params do
requires :token, type: String
requires :course_id, type: Integer, desc: "课程id"
end
get 'teachers' do
cs = CoursesService.new
teachers = cs.course_teacher_or_student_list({role: 1}, params[:course_id],current_user)
{status: 0, data: teachers}
teachers = cs.course_teacher_or_student_list({role: '1'}, params[:course_id],current_user)
present :data, teachers, with: Mobile::Entities::User
present :status, 0
end
desc "课程学生列表"
params do
requires :token, type: String
requires :course_id, type: Integer, desc: "课程id"
end
get 'teachers' do
get 'students' do
cs = CoursesService.new
teachers = cs.course_teacher_or_student_list({role: 2}, params[:course_id],current_user)
{status: 0, data: teachers}
students = cs.course_teacher_or_student_list({role: '2'}, params[:course_id],current_user)
present :data, students, with: Mobile::Entities::User
present :status, 0
end
desc "返回单个课程"

View File

@ -72,7 +72,36 @@ class CoursesService
#@subPage_title = ''
@members = c.member_principals.includes(:roles, :principal).all.sort
end
@members
users = []
@members.each do |m|
img_url = url_to_avatar(m.user)
gender = m.user.user_extensions.gender.nil? ? 0 : m.user.user_extensions.gender
work_unit = get_user_work_unit m.user
location = get_user_location m.user
users << {:id => m.user.id, :img_url => img_url, :nickname => m.user.login, :gender => gender, :work_unit => work_unit, :mail => m.user.mail, :location => location, :brief_introduction => m.user.user_extensions.brief_introduction}
end
users
end
#获取用户的工作单位
def get_user_work_unit user
work_unit = ""
if user.user_extensions.identity == 0 || user.user_extensions.identity == 1
work_unit = user.user_extensions.school.name unless user.user_extensions.school.nil?
elsif user.user_extensions.identity == 3
work_unit = user.user_extensions.occupation
elsif user.user_extensions.identity == 2
work_unit = user.firstname
end
work_unit
end
#获取用户地区
def get_user_location user
location = ""
location << (user.user_extensions.location || '')
location << (user.user_extensions.location_city || '')
location
end
#课程通知列表