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.
|
|
|
class Admins::CompetitionBasicSettingService < ApplicationService
|
|
|
|
attr_reader :competition, :params
|
|
|
|
|
|
|
|
def initialize(competition, params)
|
|
|
|
@params = params
|
|
|
|
@competition = competition
|
|
|
|
end
|
|
|
|
|
|
|
|
def call
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
competition.name = strip params[:name]
|
|
|
|
competition.sub_title = strip params[:sub_title]
|
|
|
|
competition.start_time = params[:start_time]
|
|
|
|
competition.end_time = params[:end_time]
|
|
|
|
competition.mode = params[:mode]
|
|
|
|
competition.identifier = strip params[:identifier]
|
|
|
|
competition.bonus = params[:bonus]
|
|
|
|
competition.awards_count = params[:awards_count]
|
|
|
|
competition.description = strip params[:description]
|
|
|
|
|
|
|
|
competition.save!
|
|
|
|
|
|
|
|
if competition.mode == 1 || competition.mode == 4
|
|
|
|
competition.competition_mode_setting&.destroy
|
|
|
|
else
|
|
|
|
setting = competition.competition_mode_setting || CompetitionModeSetting.create!(competition_id: competition.id)
|
|
|
|
if competition.mode == 2
|
|
|
|
setting.course_id = params[:course_id]
|
|
|
|
elsif competition.mode == 3
|
|
|
|
setting.start_time = params[:teach_start_time]
|
|
|
|
setting.end_time = params[:teach_end_time]
|
|
|
|
end
|
|
|
|
setting.save!
|
|
|
|
end
|
|
|
|
|
|
|
|
competition
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|