小程序接口

dev_home
cxt 5 years ago
parent 7e4c435f21
commit a7af3f4a6d

@ -1,6 +1,6 @@
class Weapps::CoursesController < Weapps::BaseController
# before_action :require_wechat_login!
before_action :teacher_allowed, except: [:create]
before_action :teacher_allowed, except: [:create, :show]
def create
return render_error("只有老师身份才能创建课堂") unless current_user.is_teacher?
@ -17,16 +17,25 @@ class Weapps::CoursesController < Weapps::BaseController
end
def update
Weapps::UpdateCourseService.call(current_course, course_params)
Weapps::UpdateCourseService.call(current_course, update_course_params)
render_ok
end
def show
@course = current_course
@current_user = current_user
end
private
def course_params
params.permit(:name, :course_list_name, :credit, course_module_types: [])
end
def update_course_params
params.permit(:name, :course_list_name, :credit)
end
def current_course
@_current_course = Course.find params[:id]
end

@ -0,0 +1,4 @@
json.(@course, :id, :name, :course_members_count, :credit)
json.teachers_count @course.teachers.count
json.students_count @course.students.count
json.course_identity @current_user.course_identity(@course)

@ -880,7 +880,7 @@ Rails.application.routes.draw do
post :cancel_sticky, on: :collection
end
resources :courses, only: [:create, :update, :edit]
resources :courses, only: [:create, :update, :edit, :show]
end
resources :users_for_partners, only: [:index]

Loading…
Cancel
Save