| | |
| | | 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; |
| | |
| | | /** |
| | | * 文件关联表 Service 实现类 |
| | | * |
| | | * @author 芋道源码 |
| | | * @author 超级管理员 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class SystemStorageAttachmentServiceImpl implements SystemStorageAttachmentService { |
| | | |
| | | private final StorageFileUtil fileUtil; |
| | | private final SystemStorageAttachmentMapper attachmentMapper; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | @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) { |