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.
31 lines
820 B
31 lines
820 B
6 years ago
|
class Ecs::MajorManagersController < Ecs::BaseController
|
||
|
skip_before_action :check_user_permission!
|
||
|
before_action :check_manager_permission!
|
||
|
|
||
|
def create
|
||
|
@user = Ecs::CreateMajorManagerService.call(current_major_school, params[:user_id])
|
||
|
rescue Ecs::CreateMajorManagerService::Error => ex
|
||
|
render_error(ex.message)
|
||
|
end
|
||
|
|
||
|
def destroy
|
||
|
# params[:id] 为 user_id
|
||
|
manager = current_major_school.ec_major_school_users.find_by(user_id: params[:id])
|
||
|
return render_error('不存在该专业管理员!') if manager.blank?
|
||
|
|
||
|
manager.destroy!
|
||
|
|
||
|
render_ok
|
||
|
end
|
||
|
|
||
|
private
|
||
|
|
||
|
def current_major_school
|
||
|
@_ec_major_school ||= EcMajorSchool.find(params[:ec_major_school_id])
|
||
|
end
|
||
|
|
||
|
def current_school
|
||
|
@_current_school ||= current_major_school.school
|
||
|
end
|
||
|
end
|