From 8475b9f98c8a4c95446f02be4bf2a64e359c359a Mon Sep 17 00:00:00 2001
From: liwentao <1376563863@qq.com>
Date: 星期五, 11 八月 2023 09:10:31 +0800
Subject: [PATCH] 与测试环境对比,部分代码已被人修改,删除其中的alert和部分硬编码,还原测试环境代码逻辑

---
 force-app/main/default/classes/BidAnnounceIframeController.cls |   27 +++++++++++++++++----------
 1 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/force-app/main/default/classes/BidAnnounceIframeController.cls b/force-app/main/default/classes/BidAnnounceIframeController.cls
index 2d424a7..6f2b673 100644
--- a/force-app/main/default/classes/BidAnnounceIframeController.cls
+++ b/force-app/main/default/classes/BidAnnounceIframeController.cls
@@ -8,17 +8,24 @@
     
     public void init() {
         Bid_Announcement__c bid = [select Id, Web_URL__c, Web_URL_ModifiedDate__c from Bid_Announcement__c where Id = :recordId];
-        List<Attachment> attList = [select Id, LastModifiedDate from Attachment where ParentId = :recordId order by LastModifiedDate desc limit 1];
-        Attachment att = null;
-        if (attList.size() > 0) {
-            att = attList[0];
+        // List<Attachment> attList = [select Id, LastModifiedDate from Attachment where ParentId = :recordId order by LastModifiedDate desc limit 1];
+        List<ContentDocumentLink> links = [select ContentDocumentId from ContentDocumentLink where LinkedEntityId =: recordId];
+        List<Id> idList = new List<Id>();
+        for (ContentDocumentLink link : links) {
+            idList.add(link.ContentDocumentId);
         }
-        
+        List<ContentDocument> docList = [select Id,ContentModifiedDate from ContentDocument where Id in: idList order by ContentModifiedDate desc limit 1];
+        // Attachment att = null;
+        ContentDocument doc = null;
+        if (docList.size() > 0) {
+            doc = docList[0];
+        }
+        ContentVersion version = [select Id from ContentVersion where ContentDocumentId =: doc.Id];
         if (bid.Web_URL__c != null) {
             // 涓爣閫氱煡涔RL鏇存柊鏃堕棿銆�銇ㄣ��鏈�鏂癆ttachment銇檪闁撱仺姣旇純銆佹柊銇椼亜銈傘伄銈掗仼鐢�
-            if (att != null) {
-                if (bid.Web_URL_ModifiedDate__c < att.LastModifiedDate) {
-                    iframe = '/servlet/servlet.FileDownload?file=' + att.Id;
+            if (doc != null) {
+                if (bid.Web_URL_ModifiedDate__c < doc.ContentModifiedDate) {
+                    iframe = '/sfc/servlet.shepherd/version/renditionDownload?rendition=THUMB720BY480&versionId='+ version.Id;
                 } else {
                     iframe = bid.Web_URL__c;
                 }
@@ -29,8 +36,8 @@
             }
         } else {
             // Attachment銈掗仼鐢�
-            if (att != null) {
-                iframe = '/servlet/servlet.FileDownload?file=' + att.Id;
+            if (doc != null) {
+                iframe = '/sfc/servlet.shepherd/version/renditionDownload?rendition=THUMB720BY480&versionId='+ version.Id;
             }
         }
     }

--
Gitblit v1.9.1