fix bind phone api

dev_forum
p31729568 5 years ago
parent 6c4e959630
commit 5914d83323

@ -9,13 +9,15 @@ class Users::InterestsController < Users::BaseController
extension = current_user.user_extension || current_user.build_user_extension
return render_error('请选择职业') unless %w(teacher student professional).include?(identity)
interest_ids = Array.wrap(params[:interest_ids]).map(&:to_i)
return render_error('请选择兴趣') if interest_ids.blank?
ActiveRecord::Base.transaction do
extension.update_column(:identity, identity)
# 兴趣
current_user.user_interests.delete_all
UserInterest.bulk_insert(:user_id, :repertoire_id) do |worker|
(Repertoire.pluck(:id) & Array.wrap(params[:interest_ids]).map(&:to_i)).each do |repertoire_id|
(Repertoire.pluck(:id) & interest_ids).each do |repertoire_id|
worker.add(user_id: current_user.id, repertoire_id: repertoire_id)
end
end

@ -13,7 +13,7 @@ class Users::BindPhoneService < ApplicationService
raise Error, '该手机号已被绑定' if User.where.not(id: user.id).exists?(phone: params[:phone])
code = VerificationCode.where(phone: params[:phone], code: params[:code], code_type: 5).last
code = VerificationCode.where(phone: params[:phone], code: params[:code], code_type: 4).last
raise Error, '验证码无效' unless code&.effective?
ActiveRecord::Base.transaction do

Loading…
Cancel
Save