云
19 小时以前 795bc269ba9acfae74620059c4ed64bd121aa288
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;
@@ -16,13 +17,14 @@
/**
 * 文件关联表 Service 实现类
 *
 * @author 芋道源码
 * @author 超级管理员
 */
@Service
@RequiredArgsConstructor
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) {