修改编辑课程接口
This commit is contained in:
parent
f55d8fe303
commit
f252438f85
|
@ -65,12 +65,13 @@ module Mobile
|
||||||
requires :is_public, type: Integer, desc: '是否公开 1公开 0私有'
|
requires :is_public, type: Integer, desc: '是否公开 1公开 0私有'
|
||||||
requires :open_student, type: Integer, desc: '是否公开学生列表1公开,0不公开,不公开时非课程成员无法看到学生列表'
|
requires :open_student, type: Integer, desc: '是否公开学生列表1公开,0不公开,不公开时非课程成员无法看到学生列表'
|
||||||
requires :course_type, type:Integer, desc: '暂时传1'
|
requires :course_type, type:Integer, desc: '暂时传1'
|
||||||
requires :term, type: String, desc: '学期(秋秀学期或春秀学期)'
|
requires :term, type: String, desc: '学期(秋季学期或春季学期)'
|
||||||
requires :time, type: String, desc: '年份'
|
requires :time, type: String, desc: '年份'
|
||||||
requires :class_period, type: String, desc: '学时总数'
|
requires :class_period, type: String, desc: '学时总数'
|
||||||
end
|
end
|
||||||
post do
|
post do
|
||||||
authenticate!
|
authenticate!
|
||||||
|
cs = CoursesService.new
|
||||||
cs_params = {
|
cs_params = {
|
||||||
course: params.reject{|k,v| [:term,:time,:class_period].include?(k)},
|
course: params.reject{|k,v| [:term,:time,:class_period].include?(k)},
|
||||||
term: params[:term],
|
term: params[:term],
|
||||||
|
@ -79,7 +80,7 @@ module Mobile
|
||||||
}
|
}
|
||||||
course = ::Course.find(params[:course_id])
|
course = ::Course.find(params[:course_id])
|
||||||
cs.edit_course_authorize(current_user,course)
|
cs.edit_course_authorize(current_user,course)
|
||||||
course = cs.edit_course(cs_params, course)
|
course = cs.edit_course(cs_params, course,current_user)
|
||||||
present :data, course, with: Mobile::Entities::Course
|
present :data, course, with: Mobile::Entities::Course
|
||||||
present :status, 0
|
present :status, 0
|
||||||
end
|
end
|
||||||
|
|
|
@ -95,7 +95,7 @@ class CoursesController < ApplicationController
|
||||||
#更新课程信息
|
#更新课程信息
|
||||||
def update
|
def update
|
||||||
cs = CoursesService.new
|
cs = CoursesService.new
|
||||||
@course = cs.edit_course params,@course
|
@course = cs.edit_course params,@course,User.current
|
||||||
if @course.errors.full_messages.count <= 0
|
if @course.errors.full_messages.count <= 0
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
|
|
|
@ -175,8 +175,9 @@ class CoursesService
|
||||||
#params[:term]:学期(秋季学期或春季学期)
|
#params[:term]:学期(秋季学期或春季学期)
|
||||||
#params[:time]: 年份(例:2014)
|
#params[:time]: 年份(例:2014)
|
||||||
#params[:class_period]:学时总数
|
#params[:class_period]:学时总数
|
||||||
def edit_course params,course
|
def edit_course(params,course,current_user)
|
||||||
course.safe_attributes = params[:course]
|
course.send(:safe_attributes=, params[:course], current_user)
|
||||||
|
#course.safe_attributes = params[:course]
|
||||||
course.time = params[:time]
|
course.time = params[:time]
|
||||||
course.term = params[:term]
|
course.term = params[:term]
|
||||||
course.class_period = params[:class_period]
|
course.class_period = params[:class_period]
|
||||||
|
|
Loading…
Reference in New Issue