| | |
| | | "附件绑定失败,请重新上传后再试", true, null)); |
| | | } |
| | | |
| | | /** 删除补录附件所属会话:附件关系、blob 记录与磁盘文件一并清理,附件不存在时幂等返回。 */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void deleteImportAttachment(Long attachmentId) { |
| | | SystemStorageAttachmentDO attachment = attachmentMapper.selectById(attachmentId); |
| | | if (attachment == null) { |
| | | return; |
| | | } |
| | | if (!RECORD_TYPE.equals(attachment.getRecordType())) { |
| | | throw new AgentBridgeException(HttpStatus.FORBIDDEN, "ATTACHMENT_FORBIDDEN", "附件不可访问"); |
| | | } |
| | | Long sessionId = attachment.getRecordId(); |
| | | requireOwnedSession(sessionId); |
| | | // 按会话整批删除,同一会话内被替换的旧附件行与 blob 文件都不会残留 |
| | | attachmentService.deleteAttachmentsByRecordTypeAndRecordId(RECORD_TYPE, sessionId); |
| | | sessionMapper.deleteById(sessionId); |
| | | } |
| | | |
| | | public SystemAgentAttachmentRef requireOwnedAttachmentRef(Long attachmentId) { |
| | | SystemStorageAttachmentDO attachment = attachmentMapper.selectById(attachmentId); |
| | | if (attachment == null) { |