| | |
| | | * - token使用次数控制(Redis) |
| | | * - 图片压缩 |
| | | * |
| | | * @author 芋道源码 |
| | | * @author 超级管理员 |
| | | */ |
| | | @Component |
| | | @RequiredArgsConstructor |
| | |
| | | throw new IllegalArgumentException("关联记录id不能为空"); |
| | | } |
| | | |
| | | // 删除旧附件信息 |
| | | // 只删除旧的附件关联记录,保留 blob 记录(文件本身不删除) |
| | | if (application == null || application.trim().isEmpty()) { |
| | | for (SystemStorageAttachmentSaveReqVO.BlobItem item : blobItems) { |
| | | String itemApp = item.getApplication(); |
| | | if (itemApp == null || itemApp.trim().isEmpty()) { |
| | | throw new IllegalArgumentException("文件用途不能为空"); |
| | | } |
| | | deleteStorageAttachmentsByApplicationAndRecordTypeAndRecordId(itemApp, recordType.getType(), recordId); |
| | | storageAttachmentMapper.deleteByApplicationAndRecordTypeAndRecordId(itemApp, recordType.getType(), recordId); |
| | | } |
| | | } else { |
| | | deleteStorageAttachmentsByApplicationAndRecordTypeAndRecordId(application, recordType.getType(), recordId); |
| | | storageAttachmentMapper.deleteByApplicationAndRecordTypeAndRecordId(application, recordType.getType(), recordId); |
| | | } |
| | | |
| | | if (CollUtil.isEmpty(blobItems)) { |
| | | deleteStorageAttachmentsByRecordTypeAndRecordId(recordType.getType(), recordId); |
| | | return; |
| | | } |
| | | |
| | |
| | | List<SystemStorageAttachmentDO> attachments = getStorageAttachmentsByApplicationAndRecordTypeAndRecordId( |
| | | application, recordType, recordId); |
| | | if (CollUtil.isEmpty(attachments)) { |
| | | return null; |
| | | // 返回空集合而非 null:调用方常把它直接塞进 Collectors.toMap 做分组(value 为 null 会抛 NPE) |
| | | return new ArrayList<>(); |
| | | } |
| | | Map<Long, Long> blobIdToAttachmentIdMap = attachments.stream() |
| | | .collect(Collectors.toMap(SystemStorageAttachmentDO::getStorageBlobId, SystemStorageAttachmentDO::getId)); |
| | |
| | | public List<SystemStorageBlobRespVO> getStorageBlobVOsByRecordTypeAndRecordId(String recordType, Long recordId) { |
| | | List<SystemStorageAttachmentDO> attachments = getStorageAttachmentsByRecordTypeAndRecordId(recordType, recordId); |
| | | if (CollUtil.isEmpty(attachments)) { |
| | | return null; |
| | | // 返回空集合而非 null,避免调用方直接使用返回值时抛 NPE |
| | | return new ArrayList<>(); |
| | | } |
| | | List<Long> storageBlobIds = attachments.stream() |
| | | .map(SystemStorageAttachmentDO::getStorageBlobId) |