From 67fda7b2dfbfc9e6a8d8b9472499a67906d2bad1 Mon Sep 17 00:00:00 2001
From: liyong <18434998025@163.com>
Date: 星期六, 09 五月 2026 18:05:22 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_浪潮_pro' into dev_浪潮_pro

---
 src/main/java/com/ruoyi/basic/utils/FileUtil.java |   59 ++++++++++++++++++++++++++++-------------------------------
 1 files changed, 28 insertions(+), 31 deletions(-)

diff --git a/src/main/java/com/ruoyi/basic/utils/FileUtil.java b/src/main/java/com/ruoyi/basic/utils/FileUtil.java
index 0e3d10d..b9705da 100644
--- a/src/main/java/com/ruoyi/basic/utils/FileUtil.java
+++ b/src/main/java/com/ruoyi/basic/utils/FileUtil.java
@@ -1,9 +1,7 @@
 package com.ruoyi.basic.utils;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.basic.dto.StorageAttachmentDTO;
 import com.ruoyi.basic.dto.StorageAttachmentVO;
 import com.ruoyi.basic.dto.StorageBlobDTO;
@@ -286,41 +284,20 @@
     /**
      * 閫氳繃璁板綍绫诲瀷鑾峰彇鏂囦欢淇℃伅 attachment锛堝垎椤碉級
      *
-     * @param page       鍒嗛〉鍙傛暟
      * @param storageAttachmentDTO 鍏宠仈璁板綍淇℃伅
      */
-    public IPage<StorageAttachmentVO> getStorageAttachmentVosPageListByApplicationAndRecordTypeAndRecordId(Page page, StorageAttachmentDTO storageAttachmentDTO) {
-        // 鍒嗛〉鏌ヨ绗﹀悎鏉′欢鐨� StorageAttachment 璁板綍
+    public List<StorageBlobVO> getStorageBlobVOsByApplicationAndRecordTypeAndRecordId(StorageAttachmentDTO storageAttachmentDTO) {
         LambdaQueryWrapper<StorageAttachment> queryWrapper = new LambdaQueryWrapper<StorageAttachment>()
                 .eq(StorageAttachment::getRecordType, storageAttachmentDTO.getRecordType())
                 .eq(StorageAttachment::getRecordId, storageAttachmentDTO.getRecordId());
         if (storageAttachmentDTO.getApplication() != null) {
             queryWrapper.eq(StorageAttachment::getApplication, storageAttachmentDTO.getApplication());
         }
-        IPage<StorageAttachmentVO> storageAttachmentIPage = storageAttachmentMapper.selectPage(page, queryWrapper);
-
-        // 杞崲涓� StorageAttachmentVO 骞惰幏鍙栧搴旂殑 StorageBlobVO
-        List<StorageAttachmentVO> storageAttachmentVOS = new ArrayList<>();
-        if (CollectionUtils.isNotEmpty(storageAttachmentIPage.getRecords())) {
-            for (StorageAttachment storageAttachment : storageAttachmentIPage.getRecords()) {
-                StorageAttachmentVO storageAttachmentVO = new StorageAttachmentVO();
-                BeanUtils.copyProperties(storageAttachment, storageAttachmentVO);
-                List<StorageBlobVO> storageBlobVOS = getStorageBlobVOsByStorageAttachmentIds(Collections.singletonList(storageAttachment.getId()));
-                if (CollectionUtils.isEmpty(storageBlobVOS)) {
-                    storageAttachmentVO.setStorageBlobVOS(new ArrayList<>());
-                } else {
-                    storageAttachmentVO.setStorageBlobVOS(storageBlobVOS);
-                }
-                storageAttachmentVOS.add(storageAttachmentVO);
-            }
+        List<StorageAttachment> storageAttachments = storageAttachmentMapper.selectList(queryWrapper);
+        if (CollectionUtils.isEmpty(storageAttachments)) {
+            return null;
         }
-
-        // 鏋勫缓鍒嗛〉缁撴灉
-        IPage<StorageAttachmentVO> resultPage = new Page<>();
-        BeanUtils.copyProperties(storageAttachmentIPage, resultPage);
-        resultPage.setRecords(storageAttachmentVOS);
-
-        return resultPage;
+        return getStorageBlobVOsByStorageAttachmentIds(storageAttachments.stream().map(StorageAttachment::getId).collect(Collectors.toList()));
     }
 
     /**
@@ -355,6 +332,9 @@
         if (CollectionUtils.isEmpty(storageAttachments)) {
             return null;
         }
+        Map<Long, Long> blobIdToAttachmentIdMap = storageAttachments.stream()
+                .collect(Collectors.toMap(StorageAttachment::getStorageBlobId, StorageAttachment::getId));
+
         List<Long> storageBlobIds = storageAttachments.stream().map(StorageAttachment::getStorageBlobId).collect(Collectors.toList());
         List<StorageBlob> storageBlobs = storageBlobMapper.selectByIds(storageBlobIds);
         List<StorageBlobVO> storageBlobDTOS = new ArrayList<>();
@@ -362,7 +342,10 @@
             StorageBlobVO storageBlobVO = new StorageBlobVO();
             BeanUtils.copyProperties(storageBlob, storageBlobVO);
             storageBlobVO.setPreviewURL(buildSignedPreviewUrl(storageBlobVO));
+            storageBlobVO.setUrl(buildSignedPreviewUrl(storageBlobVO));
+            storageBlobVO.setName(storageBlob.getOriginalFilename());
             storageBlobVO.setDownloadURL(buildSignedDownloadUrl(storageBlobVO));
+            storageBlobVO.setStorageAttachmentId(blobIdToAttachmentIdMap.get(storageBlob.getId()));
             storageBlobDTOS.add(storageBlobVO);
         }
         return storageBlobDTOS;
@@ -398,17 +381,24 @@
         if (CollectionUtils.isEmpty(storageAttachments)) {
             return null;
         }
+        // 鏋勫缓 storageBlobId -> storageAttachmentId 鐨勬槧灏�
+        Map<Long, Long> blobIdToAttachmentIdMap = storageAttachments.stream()
+                .collect(Collectors.toMap(StorageAttachment::getStorageBlobId, StorageAttachment::getId));
+
         List<Long> storageBlobIds = storageAttachments.stream().map(StorageAttachment::getStorageBlobId).collect(Collectors.toList());
         List<StorageBlob> storageBlobs = storageBlobMapper.selectByIds(storageBlobIds);
-        List<StorageBlobVO> storageBlobDTOS = new ArrayList<>();
+        List<StorageBlobVO> storageBlobVOS = new ArrayList<>();
         for (StorageBlob storageBlob : storageBlobs) {
             StorageBlobVO storageBlobVO = new StorageBlobVO();
             BeanUtils.copyProperties(storageBlob, storageBlobVO);
             storageBlobVO.setPreviewURL(buildSignedPreviewUrl(storageBlobVO));
             storageBlobVO.setDownloadURL(buildSignedDownloadUrl(storageBlobVO));
-            storageBlobDTOS.add(storageBlobVO);
+            storageBlobVO.setUrl(buildSignedDownloadUrl(storageBlobVO));
+            storageBlobVO.setName(storageBlob.getOriginalFilename());
+            storageBlobVO.setStorageAttachmentId(blobIdToAttachmentIdMap.get(storageBlob.getId()));
+            storageBlobVOS.add(storageBlobVO);
         }
-        return storageBlobDTOS;
+        return storageBlobVOS;
     }
 
     /**
@@ -429,6 +419,8 @@
             StorageBlobVO storageBlobVO = new StorageBlobVO();
             BeanUtils.copyProperties(storageBlob, storageBlobVO);
             storageBlobVO.setPreviewURL(buildSignedPreviewUrl(storageBlobVO));
+            storageBlobVO.setUrl(buildSignedPreviewUrl(storageBlobVO));
+            storageBlobVO.setName(storageBlob.getOriginalFilename());
             storageBlobVO.setDownloadURL(buildSignedDownloadUrl(storageBlobVO));
             storageBlobDTOS.add(storageBlobVO);
         }
@@ -448,6 +440,10 @@
         if (CollectionUtils.isEmpty(storageAttachments)) {
             return null;
         }
+        // 鏋勫缓 storageBlobId -> storageAttachmentId 鐨勬槧灏�
+        Map<Long, Long> blobIdToAttachmentIdMap = storageAttachments.stream()
+                .collect(Collectors.toMap(StorageAttachment::getStorageBlobId, StorageAttachment::getId));
+
         List<Long> storageBlobIds = storageAttachments.stream().map(StorageAttachment::getStorageBlobId).collect(Collectors.toList());
         List<StorageBlob> storageBlobs = storageBlobMapper.selectByIds(storageBlobIds);
         List<StorageBlobVO> storageBlobDTOS = new ArrayList<>();
@@ -456,6 +452,7 @@
             BeanUtils.copyProperties(storageBlob, storageBlobVO);
             storageBlobVO.setPreviewURL(buildSignedUrl(storageBlobVO, "/preview/", expired));
             storageBlobVO.setDownloadURL(buildSignedUrl(storageBlobVO, "/download/", expired));
+            storageBlobVO.setStorageAttachmentId(blobIdToAttachmentIdMap.get(storageBlob.getId()));
             storageBlobDTOS.add(storageBlobVO);
         }
         return storageBlobDTOS;

--
Gitblit v1.9.3