|
|
@ -35,16 +35,18 @@ class Admins::CompetitionBasicSettingService < ApplicationService
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 主办方设置
|
|
|
|
# 主办方设置
|
|
|
|
new_school_ids = (params[:sponsor_schools] || []) - competition.sponsor_schools.pluck(:school_id)
|
|
|
|
params[:sponsor_schools] = Array.wrap(params[:sponsor_schools]).map(&:to_i)
|
|
|
|
delete_school_ids = competition.sponsor_schools.pluck(:school_id) - (params[:sponsor_schools] || [])
|
|
|
|
new_school_ids = params[:sponsor_schools] - competition.sponsor_schools.pluck(:school_id)
|
|
|
|
|
|
|
|
delete_school_ids = competition.sponsor_schools.pluck(:school_id) - params[:sponsor_schools]
|
|
|
|
new_school_ids.each do |school_id|
|
|
|
|
new_school_ids.each do |school_id|
|
|
|
|
CompetitionSchool.create!(competition_id: competition.id, school_id: school_id, source: 'sponsor')
|
|
|
|
CompetitionSchool.create!(competition_id: competition.id, school_id: school_id, source: 'sponsor')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
competition.sponsor_schools.where(school_id: delete_school_ids).destroy_all
|
|
|
|
competition.sponsor_schools.where(school_id: delete_school_ids).destroy_all
|
|
|
|
|
|
|
|
|
|
|
|
# 开放范围设置
|
|
|
|
# 开放范围设置
|
|
|
|
new_region_school_ids = (params[:region_schools] || []) - competition.region_schools.pluck(:school_id)
|
|
|
|
params[:region_schools] = Array.wrap(params[:region_schools]).map(&:to_i)
|
|
|
|
delete_region_school_ids = competition.region_schools.pluck(:school_id) - (params[:region_schools] || [])
|
|
|
|
new_region_school_ids = params[:region_schools] - competition.region_schools.pluck(:school_id)
|
|
|
|
|
|
|
|
delete_region_school_ids = competition.region_schools.pluck(:school_id) - params[:region_schools]
|
|
|
|
new_region_school_ids.each do |school_id|
|
|
|
|
new_region_school_ids.each do |school_id|
|
|
|
|
CompetitionSchool.create!(competition_id: competition.id, school_id: school_id, source: 'region')
|
|
|
|
CompetitionSchool.create!(competition_id: competition.id, school_id: school_id, source: 'region')
|
|
|
|
end
|
|
|
|
end
|
|
|
|