From 9cf393acb08588a671aa07fa16ffda4f4f3c2db1 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Tue, 16 Jul 2019 17:24:39 +0800 Subject: [PATCH] update user info api add professional logical && fix bug --- app/models/apply_user_authentication.rb | 1 + app/models/user.rb | 2 +- app/services/users/update_account_service.rb | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/models/apply_user_authentication.rb b/app/models/apply_user_authentication.rb index 3907c3f16..c7fb5019e 100644 --- a/app/models/apply_user_authentication.rb +++ b/app/models/apply_user_authentication.rb @@ -6,4 +6,5 @@ class ApplyUserAuthentication < ApplicationRecord scope :real_name_auth, -> { where(auth_type: 1) } scope :professional_auth, -> { where(auth_type: 2) } scope :processing, -> { where(status: 0) } + scope :passed, -> { where(status: 1) } end diff --git a/app/models/user.rb b/app/models/user.rb index 49a3e9090..d089c49c3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -58,7 +58,7 @@ class User < ApplicationRecord has_many :tidings, :dependent => :destroy has_many :games, :dependent => :destroy - has_many :created_subjects + has_many :created_subjects, foreign_key: :user_id, class_name: 'Subject' has_many :subjects, :through => :subject_members has_many :subject_members, :dependent => :destroy has_many :grades, :dependent => :destroy diff --git a/app/services/users/update_account_service.rb b/app/services/users/update_account_service.rb index 6a8588dee..d603cec8c 100644 --- a/app/services/users/update_account_service.rb +++ b/app/services/users/update_account_service.rb @@ -35,6 +35,13 @@ class Users::UpdateAccountService < ApplicationService extension.technical_title = params[:technical_title] end + # 职业、学校变动需要重新进行职业认证 + if extension.identity_changed? || extension.school_id_changed? + user.professional_certification = false + # 撤销之前的职业认证 + user.apply_user_authentication.professional_auth.passed.update_all(status: 3) + end + # 表示资料完整 user.profile_completed = true