You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.3 KiB
38 lines
1.3 KiB
class Ecs::EcGraduationRequirementsController < Ecs::BaseController
|
|
skip_before_action :check_user_permission!, only: [:create, :update]
|
|
before_action :check_major_manager_permission!, only: [:create, :update]
|
|
|
|
def index
|
|
@graduation_requirements = current_year.ec_graduation_requirements.includes(:ec_graduation_subitems)
|
|
|
|
respond_to do |format|
|
|
format.json
|
|
format.xlsx do
|
|
filename = "#{current_year.year}届毕业要求及指导点_#{Time.current.strftime('%Y%m%d%H%M%S')}.xlsx"
|
|
render xlsx: 'index', filename: filename
|
|
end
|
|
end
|
|
end
|
|
|
|
def create
|
|
graduation_requirement = current_year.graduation_requirements.new
|
|
@graduation_requirement = Ecs::SaveGraduationRequirementeService.call(graduation_requirement, create_params)
|
|
render 'show'
|
|
end
|
|
|
|
def update
|
|
graduation_requirement = current_year.graduation_requirements.find(params[:id])
|
|
@graduation_requirement = Ecs::SaveGraduationRequirementeService.call(graduation_requirement, update_params)
|
|
render 'show'
|
|
end
|
|
|
|
private
|
|
|
|
def create_params
|
|
params.permit(:position, :content, graduation_subitems: [:content])
|
|
end
|
|
|
|
def update_params
|
|
params.permit(:position, :content, graduation_subitems: [:id, :content])
|
|
end
|
|
end |