Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun
commit
e29cfbda4e
@ -1,24 +0,0 @@
|
||||
class Weapps::RegisterCodesController < Weapps::BaseController
|
||||
before_action :require_wechat_login!
|
||||
|
||||
def create
|
||||
login = params[:login].to_s.strip
|
||||
if login =~ /^[a-zA-Z0-9]+([._\\]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/
|
||||
user = User.find_by(mail: login)
|
||||
return render_error('该邮箱已注册') if user.present?
|
||||
elsif login =~ /^1\d{10}$/
|
||||
user = User.find_by(phone: params[:login])
|
||||
return render_error('该手机号已注册') if user.present?
|
||||
else
|
||||
return render_error('请输入正确的邮箱或手机号')
|
||||
end
|
||||
|
||||
code = %W(0 1 2 3 4 5 6 7 8 9)
|
||||
verification_code = code.sample(6).join
|
||||
send_type = login =~ /^1\d{10}$/ ? 1 : 8
|
||||
# 记录验证码
|
||||
check_verification_code(verification_code, send_type, login)
|
||||
|
||||
render_ok
|
||||
end
|
||||
end
|
@ -0,0 +1,51 @@
|
||||
class Weapps::VerificationCodesController < Weapps::BaseController
|
||||
before_action :require_wechat_login!
|
||||
|
||||
def create
|
||||
params[:type] == 'register' ? check_can_register : check_can_reset_password
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_can_register
|
||||
login = params[:login].to_s.strip
|
||||
if login =~ /^[a-zA-Z0-9]+([._\\]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/
|
||||
user = User.find_by(mail: login)
|
||||
return render_error('该邮箱已注册') if user.present?
|
||||
elsif login =~ /^1\d{10}$/
|
||||
user = User.find_by(phone: params[:login])
|
||||
return render_error('该手机号已注册') if user.present?
|
||||
else
|
||||
return render_error('请输入正确的邮箱或手机号')
|
||||
end
|
||||
|
||||
code = %W(0 1 2 3 4 5 6 7 8 9)
|
||||
verification_code = code.sample(6).join
|
||||
send_type = login =~ /^1\d{10}$/ ? 1 : 8
|
||||
# 记录验证码
|
||||
check_verification_code(verification_code, send_type, login)
|
||||
|
||||
render_ok
|
||||
end
|
||||
|
||||
def check_can_reset_password
|
||||
login = params[:login].to_s.strip
|
||||
if login =~ /^[a-zA-Z0-9]+([._\\]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/
|
||||
user = User.find_by(mail: login)
|
||||
return render_error('该邮箱尚未注册') if user.blank?
|
||||
elsif login =~ /^1\d{10}$/
|
||||
user = User.find_by(phone: login)
|
||||
return render_error('该手机号尚未注册') if user.blank?
|
||||
else
|
||||
return render_error('请输入正确的邮箱或手机号')
|
||||
end
|
||||
|
||||
code = %W(0 1 2 3 4 5 6 7 8 9)
|
||||
verification_code = code.sample(6).join
|
||||
send_type = login =~ /^1\d{10}$/ ? 2 : 3
|
||||
# 记录验证码
|
||||
check_verification_code(verification_code, send_type, login)
|
||||
|
||||
render_ok
|
||||
end
|
||||
end
|
@ -1,2 +1,3 @@
|
||||
class WeappSettings::Advert < WeappSetting
|
||||
default_scope { order(position: :asc) }
|
||||
end
|
@ -0,0 +1,29 @@
|
||||
class Admins::CompetitionStageCreateService < ApplicationService
|
||||
attr_reader :competition, :params
|
||||
|
||||
def initialize(competition, params)
|
||||
@params = params
|
||||
@competition = competition
|
||||
end
|
||||
|
||||
def call
|
||||
ActiveRecord::Base.transaction do
|
||||
stage = CompetitionStage.create!(competition_id: competition.id, name: params[:stage_name], score_rate: (params[:score_rate].to_i / 100).round(2))
|
||||
|
||||
stage.competition_stage_sections.destroy_all
|
||||
|
||||
params[:stage].each do |section|
|
||||
stage_section = CompetitionStageSection.create!(competition_id: competition.id, competition_stage_id: stage.id,
|
||||
start_time: section["start_time"], end_time: section["end_time"],
|
||||
mission_count: section["mission_count"], entry: section["entry"],
|
||||
score_source: section["score_source"])
|
||||
section["identifiers"].each do |identifier|
|
||||
CompetitionEntry.create!(competition_stage_section_id: stage_section.id, competition_stage_id: stage.id,
|
||||
shixun_identifier: identifier)
|
||||
end
|
||||
end
|
||||
|
||||
stage
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,30 @@
|
||||
class Admins::CompetitionStageUpdateService < ApplicationService
|
||||
attr_reader :competition, :params, :stage
|
||||
|
||||
def initialize(competition, params, stage)
|
||||
@params = params
|
||||
@competition = competition
|
||||
@stage = stage
|
||||
end
|
||||
|
||||
def call
|
||||
ActiveRecord::Base.transaction do
|
||||
stage.update_attributes!(name: params[:stage_name], score_rate: (params[:score_rate].to_i / 100).round(2))
|
||||
|
||||
stage.competition_stage_sections.destroy_all
|
||||
|
||||
params[:stage].each do |section|
|
||||
stage_section = CompetitionStageSection.create!(competition_id: competition.id, competition_stage_id: stage.id,
|
||||
start_time: section["start_time"], end_time: section["end_time"],
|
||||
mission_count: section["mission_count"], entry: section["entry"],
|
||||
score_source: section["score_source"])
|
||||
section["identifiers"].each do |identifier|
|
||||
CompetitionEntry.create!(competition_stage_section_id: stage_section.id, competition_stage_id: stage.id,
|
||||
shixun_identifier: identifier)
|
||||
end
|
||||
end
|
||||
|
||||
stage
|
||||
end
|
||||
end
|
||||
end
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Loading…
Reference in new issue