From d39e4f7d839167c16425086dfa2f8747bccfdff9 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 05 十一月 2026 17:39:01 +0800
Subject: [PATCH] feat: 打通销售采购财务闭环并完成累计业务优化

---
 yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/api/storage/StorageAttachmentApiImpl.java |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/api/storage/StorageAttachmentApiImpl.java b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/api/storage/StorageAttachmentApiImpl.java
index 914c89d..3808669 100644
--- a/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/api/storage/StorageAttachmentApiImpl.java
+++ b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/api/storage/StorageAttachmentApiImpl.java
@@ -18,6 +18,19 @@
     @Resource
     private SystemStorageAttachmentService systemStorageAttachmentService;
 
+    @Resource
+    private cn.iocoder.yudao.module.system.dal.mysql.storage.SystemStorageAttachmentMapper attachmentMapper;
+
+    @Override
+    @org.springframework.transaction.annotation.Transactional(rollbackFor = Exception.class)
+    public void removeReference(String application, String recordType, Long recordId, Long blobId) {
+        attachmentMapper.delete(new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<cn.iocoder.yudao.module.system.dal.dataobject.storage.SystemStorageAttachmentDO>()
+                .eq(cn.iocoder.yudao.module.system.dal.dataobject.storage.SystemStorageAttachmentDO::getApplication, application)
+                .eq(cn.iocoder.yudao.module.system.dal.dataobject.storage.SystemStorageAttachmentDO::getRecordType, recordType)
+                .eq(cn.iocoder.yudao.module.system.dal.dataobject.storage.SystemStorageAttachmentDO::getRecordId, recordId)
+                .eq(cn.iocoder.yudao.module.system.dal.dataobject.storage.SystemStorageAttachmentDO::getStorageBlobId, blobId));
+    }
+
     @Override
     public void bindAttachments(String application, String recordType, Long recordId, List<Long> blobIds) {
         if (blobIds == null || blobIds.isEmpty()) {
@@ -38,8 +51,24 @@
     }
 
     @Override
+    public void updateAttachments(String application, String recordType, Long recordId, List<Long> newBlobIds) {
+        if (newBlobIds == null) {
+            return;
+        }
+        if (newBlobIds.isEmpty()) {
+            // 娓呯┖鎵�鏈夐檮浠�
+            systemStorageAttachmentService.deleteAttachmentsByApplicationAndRecordTypeAndRecordId(
+                    application != null ? application : "file", recordType, recordId);
+            return;
+        }
+        // 鍏ㄩ噺鏇挎崲锛歜indAttachments 鍐呴儴鍏堝垹鍚庢彃锛岀洿鎺ヤ紶鍏ュ叏閮ㄦ柊 blobId 鍗冲彲
+        bindAttachments(application, recordType, recordId, newBlobIds);
+    }
+
+    @Override
     public List<StorageBlobRespDTO> listAttachments(String recordType, Long recordId) {
         SystemStorageAttachmentListReqVO reqVO = new SystemStorageAttachmentListReqVO();
+        reqVO.setApplication("file");
         reqVO.setRecordType(recordType);
         reqVO.setRecordId(recordId);
         List<SystemStorageBlobRespVO> list = systemStorageAttachmentService.listAttachments(reqVO);

--
Gitblit v1.9.3