From b29e50064576e979097479adceb61de90a8de142 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 13 Dec 2023 09:26:49 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20=E8=A7=A3=E5=86=B3=E5=AE=89=E5=85=A8?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E8=AE=BF=E9=97=AE=E9=99=84=E4=BB=B6=EF=BC=8C?= =?UTF-8?q?id=E6=94=B9=E4=B8=BAuuid,id=E6=9F=A5=E8=AF=A2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/attachment.rb | 2 +- app/models/identity_verification.rb | 2 +- app/services/api/v1/issues/concerns/checkable.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 49124a220..810474609 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -69,7 +69,7 @@ class Attachment < ApplicationRecord scope :simple_columns, -> { select(:id, :filename, :filesize, :created_on, :cloud_url, :author_id, :content_type, :container_type, :container_id) } scope :search_by_container, -> (ids) {where(container_id: ids)} scope :unified_setting, -> {where("unified_setting = ? ", 1)} - scope :where_id_or_uuid, -> (id) { where("id = ? or uuid= ? ", id, id) } + scope :where_id_or_uuid, -> (id) { (Float(id) rescue nil).present? ? where(id: id) : where(uuid: id) } validates_length_of :description, maximum: 100, message: "不能超过100个字符" diff --git a/app/models/identity_verification.rb b/app/models/identity_verification.rb index 9d7667635..fdef74d43 100644 --- a/app/models/identity_verification.rb +++ b/app/models/identity_verification.rb @@ -24,7 +24,7 @@ class IdentityVerification < ApplicationRecord belongs_to :user enum state: { "待审核": 0, "已通过": 1, "已拒绝": 2} after_create do - Attachment.where(id:[card_front,card_back,hold_card_front,hold_card_back]).update_all(is_public:0) + Attachment.where(uuid:[card_front,card_back,hold_card_front,hold_card_back]).update_all(is_public:0) end after_save do diff --git a/app/services/api/v1/issues/concerns/checkable.rb b/app/services/api/v1/issues/concerns/checkable.rb index 7d163ada6..5eef81584 100644 --- a/app/services/api/v1/issues/concerns/checkable.rb +++ b/app/services/api/v1/issues/concerns/checkable.rb @@ -31,7 +31,7 @@ module Api::V1::Issues::Concerns::Checkable def check_attachments (attachment_ids) raise ApplicationService::Error, "请输入正确的附件ID数组!" unless attachment_ids.is_a?(Array) attachment_ids.each do |aid| - raise ApplicationService::Error, "请输入正确的附件ID!" unless Attachment.where("id=? or uuid=?", aid, aid).exists? + raise ApplicationService::Error, "请输入正确的附件ID!" unless Attachment.where_id_or_uuid(aid).exists? end end