From b4a9e12e00b78e1aef8acda070434de9ffd0d66a Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期五, 24 四月 2026 15:29:19 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_New_pro' into dev_New_pro

---
 src/main/java/com/ruoyi/basic/utils/FileUtil.java |   66 ++++++++++++++++++++++++--------
 1 files changed, 49 insertions(+), 17 deletions(-)

diff --git a/src/main/java/com/ruoyi/basic/utils/FileUtil.java b/src/main/java/com/ruoyi/basic/utils/FileUtil.java
index d0cd8a6..4092f30 100644
--- a/src/main/java/com/ruoyi/basic/utils/FileUtil.java
+++ b/src/main/java/com/ruoyi/basic/utils/FileUtil.java
@@ -74,6 +74,7 @@
             storageAttachment.setRecordId(recordId);
             storageAttachment.setStorageBlobId(storageBlobDTO.getId());
             storageAttachment.setDeleted(0L);
+            storageAttachments.add(storageAttachment);
         }
         storageAttachmentMapper.insert(storageAttachments);
     }
@@ -103,10 +104,10 @@
      *
      * @param application 鏂囦欢鐢ㄩ��
      * @param recordType  鍏宠仈璁板綍绫诲瀷
-     * @param recordId    鍏宠仈璁板綍id
+     * @param recordIds    鍏宠仈璁板綍id
      */
-    public void deleteStorageBlobsByApplicationAndRecordTypeAndRecordId(ApplicationTypeEnum application, RecordTypeEnum recordType, Long recordId) {
-        if (recordId == null || recordId <= 0) {
+    public void deleteStorageBlobsByApplicationAndRecordTypeAndRecordIds(ApplicationTypeEnum application, RecordTypeEnum recordType, List<Long> recordIds) {
+        if (recordIds == null || recordIds.isEmpty()) {
             throw new RuntimeException("鍏宠仈璁板綍id涓嶈兘涓虹┖");
         }
         if (application == null) {
@@ -117,7 +118,7 @@
         }
         List<StorageAttachment> storageAttachments = storageAttachmentMapper.selectList(new LambdaQueryWrapper<StorageAttachment>()
                 .eq(StorageAttachment::getRecordType, recordType.getType())
-                .eq(StorageAttachment::getRecordId, recordId)
+                .in(StorageAttachment::getRecordId, recordIds)
                 .eq(StorageAttachment::getApplication, application.getType()));
         if (CollectionUtils.isNotEmpty(storageAttachments)) {
             List<Long> storageAttachmentIds = storageAttachments.stream().map(StorageAttachment::getStorageBlobId)
@@ -136,6 +137,13 @@
         storageAttachmentMapper.deleteByIds(storageAttachmentIds);
     }
 
+    /**
+     * 鍒犻櫎鏂囦欢鍏宠仈淇℃伅
+     *
+     * @param application 鏂囦欢鐢ㄩ��
+     * @param recordType  鍏宠仈璁板綍绫诲瀷
+     * @param recordId    鍏宠仈璁板綍id
+     */
     public void deleteStorageAttachmentsByApplicationAndRecordTypeAndRecordId(ApplicationTypeEnum application, RecordTypeEnum recordType, Long recordId) {
         if (recordId == null || recordId <= 0) {
             throw new RuntimeException("鍏宠仈璁板綍id涓嶈兘涓虹┖");
@@ -146,10 +154,34 @@
         if (recordType == null) {
             throw new RuntimeException("鍏宠仈璁板綍绫诲瀷涓嶈兘涓虹┖");
         }
-        deleteStorageBlobsByApplicationAndRecordTypeAndRecordId(application, recordType, recordId);
+        deleteStorageBlobsByApplicationAndRecordTypeAndRecordIds(application, recordType, Arrays.asList(recordId));
         storageAttachmentMapper.delete(new LambdaQueryWrapper<StorageAttachment>()
                 .eq(StorageAttachment::getRecordType, recordType.getType())
                 .eq(StorageAttachment::getRecordId, recordId)
+                .eq(StorageAttachment::getApplication, application.getType()));
+    }
+
+    /**
+     * 鎵归噺鍒犻櫎鏂囦欢鍏宠仈淇℃伅 attachment
+     *
+     * @param application 鏂囦欢鐢ㄩ��
+     * @param recordType  鍏宠仈璁板綍绫诲瀷
+     * @param recordIds   鍏宠仈璁板綍id
+     */
+    public void deleteStorageAttachmentsByApplicationAndRecordTypeAndRecordIds(ApplicationTypeEnum application, RecordTypeEnum recordType, List<Long> recordIds) {
+        if (recordIds == null || recordIds.isEmpty()) {
+            throw new RuntimeException("鍏宠仈璁板綍id涓嶈兘涓虹┖");
+        }
+        if (application == null) {
+            throw new RuntimeException("鏂囦欢鐢ㄩ�斾笉鑳戒负绌�");
+        }
+        if (recordType == null) {
+            throw new RuntimeException("鍏宠仈璁板綍绫诲瀷涓嶈兘涓虹┖");
+        }
+        deleteStorageBlobsByApplicationAndRecordTypeAndRecordIds(application, recordType, recordIds);
+        storageAttachmentMapper.delete(new LambdaQueryWrapper<StorageAttachment>()
+                .eq(StorageAttachment::getRecordType, recordType.getType())
+                .in(StorageAttachment::getRecordId, recordIds)
                 .eq(StorageAttachment::getApplication, application.getType()));
     }
 
@@ -192,7 +224,7 @@
      *
      * @param storageAttachmentIds 鏂囦欢id
      */
-    public List<StorageBlobVO> getStorageBlobDTOsByStorageAttachmentIds(List<Long> storageAttachmentIds) {
+    public List<StorageBlobVO> getStorageBlobVOsByStorageAttachmentIds(List<Long> storageAttachmentIds) {
         List<StorageAttachment> storageAttachments = getStorageAttachmentsByStorageAttachmentIds(storageAttachmentIds);
         if (CollectionUtils.isEmpty(storageAttachments)) {
             return null;
@@ -217,7 +249,7 @@
      * @param recordType  鍏宠仈璁板綍绫诲瀷
      * @param recordId    鍏宠仈璁板綍id
      */
-    public List<StorageBlobVO> getStorageBlobDTOsByApplicationAndRecordTypeAndRecordId(ApplicationTypeEnum application, RecordTypeEnum recordType, Long recordId) {
+    public List<StorageBlobVO> getStorageBlobVOsByApplicationAndRecordTypeAndRecordId(ApplicationTypeEnum application, RecordTypeEnum recordType, Long recordId) {
         List<StorageAttachment> storageAttachments = getStorageAttachmentsByApplicationAndRecordTypeAndRecordId(application, recordType, recordId);
         if (CollectionUtils.isEmpty(storageAttachments)) {
             return null;
@@ -243,7 +275,7 @@
      * @param recordId    鍏宠仈璁板綍id
      * @param expired     杩囨湡鏃堕棿
      */
-    public List<StorageBlobVO> getStorageBlobDTOsByApplicationAndRecordTypeAndRecordId(ApplicationTypeEnum application, RecordTypeEnum recordType, Long recordId, BigDecimal expired) {
+    public List<StorageBlobVO> getStorageBlobVOsByApplicationAndRecordTypeAndRecordId(ApplicationTypeEnum application, RecordTypeEnum recordType, Long recordId, BigDecimal expired) {
         List<StorageAttachment> storageAttachments = getStorageAttachmentsByApplicationAndRecordTypeAndRecordId(application, recordType, recordId);
         if (CollectionUtils.isEmpty(storageAttachments)) {
             return null;
@@ -267,7 +299,7 @@
      * @param storageAttachmentIds 鏂囦欢id
      * @param expired              杩囨湡鏃堕棿
      */
-    public List<StorageBlobVO> getStorageBlobDTOsByStorageAttachmentIds(List<Long> storageAttachmentIds, BigDecimal expired) {
+    public List<StorageBlobVO> getStorageBlobVOsByStorageAttachmentIds(List<Long> storageAttachmentIds, BigDecimal expired) {
         List<StorageAttachment> storageAttachments = getStorageAttachmentsByStorageAttachmentIds(storageAttachmentIds);
         if (CollectionUtils.isEmpty(storageAttachments)) {
             return null;
@@ -299,7 +331,7 @@
         for (StorageAttachment storageAttachment : storageAttachments) {
             StorageAttachmentVO storageAttachmentVO = new StorageAttachmentVO();
             BeanUtils.copyProperties(storageAttachment, storageAttachmentVO);
-            List<StorageBlobVO> storageBlobVOS = getStorageBlobDTOsByStorageAttachmentIds(Collections.singletonList(storageAttachment.getId()));
+            List<StorageBlobVO> storageBlobVOS = getStorageBlobVOsByStorageAttachmentIds(Collections.singletonList(storageAttachment.getId()));
             if (CollectionUtils.isEmpty(storageBlobVOS)) {
                 storageAttachmentVO.setStorageBlobVOS(new ArrayList<>());
             } else {
@@ -325,7 +357,7 @@
         for (StorageAttachment storageAttachment : storageAttachments) {
             StorageAttachmentVO storageAttachmentVO = new StorageAttachmentVO();
             BeanUtils.copyProperties(storageAttachment, storageAttachmentVO);
-            List<StorageBlobVO> storageBlobVOS = getStorageBlobDTOsByStorageAttachmentIds(Collections.singletonList(storageAttachment.getId()), expired);
+            List<StorageBlobVO> storageBlobVOS = getStorageBlobVOsByStorageAttachmentIds(Collections.singletonList(storageAttachment.getId()), expired);
             if (CollectionUtils.isEmpty(storageBlobVOS)) {
                 storageAttachmentVO.setStorageBlobVOS(new ArrayList<>());
             } else {
@@ -352,7 +384,7 @@
         for (StorageAttachment storageAttachment : storageAttachments) {
             StorageAttachmentVO storageAttachmentVO = new StorageAttachmentVO();
             BeanUtils.copyProperties(storageAttachment, storageAttachmentVO);
-            List<StorageBlobVO> storageBlobVOS = getStorageBlobDTOsByStorageAttachmentIds(Collections.singletonList(storageAttachment.getId()));
+            List<StorageBlobVO> storageBlobVOS = getStorageBlobVOsByStorageAttachmentIds(Collections.singletonList(storageAttachment.getId()));
             if (CollectionUtils.isEmpty(storageBlobVOS)) {
                 storageAttachmentVO.setStorageBlobVOS(new ArrayList<>());
             } else {
@@ -380,7 +412,7 @@
         for (StorageAttachment storageAttachment : storageAttachments) {
             StorageAttachmentVO storageAttachmentVO = new StorageAttachmentVO();
             BeanUtils.copyProperties(storageAttachment, storageAttachmentVO);
-            List<StorageBlobVO> storageBlobVOS = getStorageBlobDTOsByStorageAttachmentIds(Collections.singletonList(storageAttachment.getId()), expired);
+            List<StorageBlobVO> storageBlobVOS = getStorageBlobVOsByStorageAttachmentIds(Collections.singletonList(storageAttachment.getId()), expired);
             if (CollectionUtils.isEmpty(storageBlobVOS)) {
                 storageAttachmentVO.setStorageBlobVOS(new ArrayList<>());
             } else {
@@ -398,7 +430,7 @@
      */
     public List<String> getFilePreviewURLByStorageAttachmentIds(List<Long> storageAttachmentIds) {
         List<String> res = new ArrayList<>();
-        List<StorageBlobVO> storageBlobVOS = getStorageBlobDTOsByStorageAttachmentIds(storageAttachmentIds);
+        List<StorageBlobVO> storageBlobVOS = getStorageBlobVOsByStorageAttachmentIds(storageAttachmentIds);
         for (StorageBlobVO storageBlobVO : storageBlobVOS) {
             res.add(buildSignedPreviewUrl(storageBlobVO));
         }
@@ -413,7 +445,7 @@
      */
     public List<String> getFilePreviewURLByStorageAttachmentIds(List<Long> storageAttachmentIds, BigDecimal expired) {
         List<String> res = new ArrayList<>();
-        List<StorageBlobVO> storageBlobVOS = getStorageBlobDTOsByStorageAttachmentIds(storageAttachmentIds);
+        List<StorageBlobVO> storageBlobVOS = getStorageBlobVOsByStorageAttachmentIds(storageAttachmentIds);
         for (StorageBlobVO storageBlobVO : storageBlobVOS) {
             res.add(buildSignedUrl(storageBlobVO, "/preview/", expired));
         }
@@ -427,7 +459,7 @@
      */
     public List<String> getFileDownloadURLByStorageAttachmentIds(List<Long> storageAttachmentIds) {
         List<String> res = new ArrayList<>();
-        List<StorageBlobVO> storageBlobVOS = getStorageBlobDTOsByStorageAttachmentIds(storageAttachmentIds);
+        List<StorageBlobVO> storageBlobVOS = getStorageBlobVOsByStorageAttachmentIds(storageAttachmentIds);
         for (StorageBlobVO storageBlobVO : storageBlobVOS) {
             res.add(buildSignedDownloadUrl(storageBlobVO));
         }
@@ -442,7 +474,7 @@
      */
     public List<String> getFileDownloadURLByStorageAttachmentIds(List<Long> storageAttachmentIds, BigDecimal expired) {
         List<String> res = new ArrayList<>();
-        List<StorageBlobVO> storageBlobVOS = getStorageBlobDTOsByStorageAttachmentIds(storageAttachmentIds);
+        List<StorageBlobVO> storageBlobVOS = getStorageBlobVOsByStorageAttachmentIds(storageAttachmentIds);
         for (StorageBlobVO storageBlobVO : storageBlobVOS) {
             res.add(buildSignedUrl(storageBlobVO, "/download/", expired));
         }

--
Gitblit v1.9.3