修复课程教师,课程学生接口
This commit is contained in:
parent
303752fc7e
commit
fdb38c1b87
|
@ -140,22 +140,26 @@ module Mobile
|
||||||
|
|
||||||
desc "课程老师列表"
|
desc "课程老师列表"
|
||||||
params do
|
params do
|
||||||
|
requires :token, type: String
|
||||||
requires :course_id, type: Integer, desc: "课程id"
|
requires :course_id, type: Integer, desc: "课程id"
|
||||||
end
|
end
|
||||||
get 'teachers' do
|
get 'teachers' do
|
||||||
cs = CoursesService.new
|
cs = CoursesService.new
|
||||||
teachers = cs.course_teacher_or_student_list({role: 1}, params[:course_id],current_user)
|
teachers = cs.course_teacher_or_student_list({role: '1'}, params[:course_id],current_user)
|
||||||
{status: 0, data: teachers}
|
present :data, teachers, with: Mobile::Entities::User
|
||||||
|
present :status, 0
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "课程学生列表"
|
desc "课程学生列表"
|
||||||
params do
|
params do
|
||||||
|
requires :token, type: String
|
||||||
requires :course_id, type: Integer, desc: "课程id"
|
requires :course_id, type: Integer, desc: "课程id"
|
||||||
end
|
end
|
||||||
get 'teachers' do
|
get 'students' do
|
||||||
cs = CoursesService.new
|
cs = CoursesService.new
|
||||||
teachers = cs.course_teacher_or_student_list({role: 2}, params[:course_id],current_user)
|
students = cs.course_teacher_or_student_list({role: '2'}, params[:course_id],current_user)
|
||||||
{status: 0, data: teachers}
|
present :data, students, with: Mobile::Entities::User
|
||||||
|
present :status, 0
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "返回单个课程"
|
desc "返回单个课程"
|
||||||
|
|
|
@ -72,7 +72,36 @@ class CoursesService
|
||||||
#@subPage_title = ''
|
#@subPage_title = ''
|
||||||
@members = c.member_principals.includes(:roles, :principal).all.sort
|
@members = c.member_principals.includes(:roles, :principal).all.sort
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
#课程通知列表
|
#课程通知列表
|
||||||
|
|
Loading…
Reference in New Issue