From 795bc269ba9acfae74620059c4ed64bd121aa288 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期四, 22 十月 2026 12:23:00 +0800
Subject: [PATCH] feat(mdm): 打通智能体物料导入端到端链路

---
 yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/storage/SystemStorageAttachmentServiceImpl.java |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/storage/SystemStorageAttachmentServiceImpl.java b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/storage/SystemStorageAttachmentServiceImpl.java
index 7930ef0..f4df43f 100644
--- a/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/storage/SystemStorageAttachmentServiceImpl.java
+++ b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/storage/SystemStorageAttachmentServiceImpl.java
@@ -6,6 +6,7 @@
 import cn.iocoder.yudao.module.system.enums.storage.StorageApplicationTypeEnum;
 import cn.iocoder.yudao.module.system.enums.storage.StorageRecordTypeEnum;
 import cn.iocoder.yudao.module.system.util.storage.StorageFileUtil;
+import cn.iocoder.yudao.module.system.dal.mysql.storage.SystemStorageAttachmentMapper;
 import jakarta.annotation.Resource;
 import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Service;
@@ -23,6 +24,7 @@
 public class SystemStorageAttachmentServiceImpl implements SystemStorageAttachmentService {
 
     private final StorageFileUtil fileUtil;
+    private final SystemStorageAttachmentMapper attachmentMapper;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -47,9 +49,21 @@
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void deleteAttachments(List<Long> ids) {
+        assertNoAgentImportAttachments(ids);
         fileUtil.deleteStorageAttachmentsByStorageAttachmentIds(ids);
     }
 
+    private void assertNoAgentImportAttachments(List<Long> ids) {
+        if (ids == null || ids.isEmpty()) {
+            return;
+        }
+        if (attachmentMapper.selectBatchIds(ids).stream()
+                .anyMatch(item -> "agent_import_session".equals(item.getRecordType()))) {
+            throw new org.springframework.web.server.ResponseStatusException(
+                    org.springframework.http.HttpStatus.FORBIDDEN, "鏅鸿兘浣撹ˉ褰曢檮浠惰浣跨敤琛ュ綍浼氳瘽鎺ュ彛绠$悊");
+        }
+    }
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void deleteAttachmentsByApplicationAndRecordTypeAndRecordId(String application, String recordType, Long recordId) {

--
Gitblit v1.9.3