From d2eeb28e4235edb830699e4170705f1a30027250 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 6 Nov 2019 16:26:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E5=90=8D=E8=AE=A4=E8=AF=81=E5=92=8C?= =?UTF-8?q?=E8=81=8C=E4=B8=9A=E8=AE=A4=E8=AF=81=E7=9A=84=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 1 + app/models/apply_user_authentication.rb | 1 + .../admins/identity_auths/agree_apply_service.rb | 3 ++- .../admins/identity_auths/refuse_apply_service.rb | 3 ++- .../admins/professional_auths/agree_apply_service.rb | 3 ++- .../admins/professional_auths/refuse_apply_service.rb | 3 ++- app/services/users/apply_authentication_service.rb | 6 ++++-- app/services/users/apply_professional_auth_service.rb | 6 ++++-- .../identity_authentications/shared/_list.html.erb | 4 ++-- .../professional_authentications/shared/_list.html.erb | 10 +++++----- 10 files changed, 25 insertions(+), 15 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 258ab9d83..da6e99418 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -191,6 +191,7 @@ class AttachmentsController < ApplicationController candown = current_user.member_of_course?(course) end tip_exception(403, "您没有权限进入") if course.present? && !candown + tip_exception(403, "您没有权限进入") if @file.container.is_a?(ApplyUserAuthentication) end end end diff --git a/app/models/apply_user_authentication.rb b/app/models/apply_user_authentication.rb index 4f94202f6..ad74b0261 100644 --- a/app/models/apply_user_authentication.rb +++ b/app/models/apply_user_authentication.rb @@ -4,6 +4,7 @@ class ApplyUserAuthentication < ApplicationRecord belongs_to :user has_many :tidings, :as => :container, :dependent => :destroy + has_one :attachment, as: :container, dependent: :destroy scope :real_name_auth, -> { where(auth_type: 1) } scope :professional_auth, -> { where(auth_type: 2) } diff --git a/app/services/admins/identity_auths/agree_apply_service.rb b/app/services/admins/identity_auths/agree_apply_service.rb index 65a3b2376..d75a6d7db 100644 --- a/app/services/admins/identity_auths/agree_apply_service.rb +++ b/app/services/admins/identity_auths/agree_apply_service.rb @@ -14,7 +14,8 @@ class Admins::IdentityAuths::AgreeApplyService < ApplicationService RewardGradeService.call(user, container_id: user.id, container_type: 'Authentication', score: 500) deal_tiding! - delete_auth_file! + apply.attachment&.destroy + # delete_auth_file! end end diff --git a/app/services/admins/identity_auths/refuse_apply_service.rb b/app/services/admins/identity_auths/refuse_apply_service.rb index 57581dd40..7ac2e6c38 100644 --- a/app/services/admins/identity_auths/refuse_apply_service.rb +++ b/app/services/admins/identity_auths/refuse_apply_service.rb @@ -12,7 +12,8 @@ class Admins::IdentityAuths::RefuseApplyService < ApplicationService apply.update!(status: 2, remarks: reason) deal_tiding! - delete_auth_file! + apply.attachment&.destroy + # delete_auth_file! end end diff --git a/app/services/admins/professional_auths/agree_apply_service.rb b/app/services/admins/professional_auths/agree_apply_service.rb index 81654f0d3..1ca2da2fc 100644 --- a/app/services/admins/professional_auths/agree_apply_service.rb +++ b/app/services/admins/professional_auths/agree_apply_service.rb @@ -14,7 +14,8 @@ class Admins::ProfessionalAuths::AgreeApplyService < ApplicationService RewardGradeService.call(user, container_id: user.id, container_type: 'Professional', score: 500) deal_tiding! - delete_auth_file! + apply.attachment&.destroy + # delete_auth_file! end end diff --git a/app/services/admins/professional_auths/refuse_apply_service.rb b/app/services/admins/professional_auths/refuse_apply_service.rb index b5332c999..a055488c3 100644 --- a/app/services/admins/professional_auths/refuse_apply_service.rb +++ b/app/services/admins/professional_auths/refuse_apply_service.rb @@ -12,7 +12,8 @@ class Admins::ProfessionalAuths::RefuseApplyService < ApplicationService apply.update!(status: 2, remarks: reason) deal_tiding! - delete_auth_file! + apply.attachment&.destroy + # delete_auth_file! end end diff --git a/app/services/users/apply_authentication_service.rb b/app/services/users/apply_authentication_service.rb index c68260dcb..cab76b45c 100644 --- a/app/services/users/apply_authentication_service.rb +++ b/app/services/users/apply_authentication_service.rb @@ -22,9 +22,11 @@ class Users::ApplyAuthenticationService < ApplicationService user.user_extension.update!(gender: params[:gender].to_i) if params[:gender].present? - user.apply_user_authentication.create!(auth_type: 1, status: 0) + apply = user.apply_user_authentication.create!(auth_type: 1, status: 0) - move_image_file! unless params[:upload_image].to_s == 'false' + Attachment.associate_container(params[:attachment_ids], apply.id, apply.class) if params[:attachment_ids] + + # move_image_file! unless params[:upload_image].to_s == 'false' end # sms_notify_admin diff --git a/app/services/users/apply_professional_auth_service.rb b/app/services/users/apply_professional_auth_service.rb index 46a4658aa..81cd11a4c 100644 --- a/app/services/users/apply_professional_auth_service.rb +++ b/app/services/users/apply_professional_auth_service.rb @@ -34,9 +34,11 @@ class Users::ApplyProfessionalAuthService < ApplicationService user.save! extension.save! - user.apply_user_authentication.create!(auth_type: 2, status: 0) + apply = user.apply_user_authentication.create!(auth_type: 2, status: 0) - move_image_file! unless params[:upload_image].to_s == 'false' + Attachment.associate_container(params[:attachment_ids], apply.id, apply.class) if params[:attachment_ids] + + # move_image_file! unless params[:upload_image].to_s == 'false' end # sms_notify_admin diff --git a/app/views/admins/identity_authentications/shared/_list.html.erb b/app/views/admins/identity_authentications/shared/_list.html.erb index c40d681ec..e1c603215 100644 --- a/app/views/admins/identity_authentications/shared/_list.html.erb +++ b/app/views/admins/identity_authentications/shared/_list.html.erb @@ -51,8 +51,8 @@ <% unless is_processed %>