| | |
| | | * |
| | | * @param application 文件用途 |
| | | * @param recordType 关联记录类型 |
| | | * @param recordId 关联记录id |
| | | * @param recordIds 关联记录id |
| | | */ |
| | | public void deleteStorageBlobsByApplicationAndRecordTypeAndRecordId(ApplicationTypeEnum application, RecordTypeEnum recordType, Long recordId) { |
| | | if (recordId == null || recordId <= 0) { |
| | | public void deleteStorageBlobsByApplicationAndRecordTypeAndRecordIds(ApplicationTypeEnum application, RecordTypeEnum recordType, List<Long> recordIds) { |
| | | if (recordIds == null || recordIds.isEmpty()) { |
| | | throw new RuntimeException("关联记录id不能为空"); |
| | | } |
| | | if (application == null) { |
| | |
| | | } |
| | | List<StorageAttachment> storageAttachments = storageAttachmentMapper.selectList(new LambdaQueryWrapper<StorageAttachment>() |
| | | .eq(StorageAttachment::getRecordType, recordType.getType()) |
| | | .eq(StorageAttachment::getRecordId, recordId) |
| | | .in(StorageAttachment::getRecordId, recordIds) |
| | | .eq(StorageAttachment::getApplication, application.getType())); |
| | | if (CollectionUtils.isNotEmpty(storageAttachments)) { |
| | | List<Long> storageAttachmentIds = storageAttachments.stream().map(StorageAttachment::getStorageBlobId) |
| | |
| | | storageAttachmentMapper.deleteByIds(storageAttachmentIds); |
| | | } |
| | | |
| | | /** |
| | | * 删除文件关联信息 |
| | | * |
| | | * @param application 文件用途 |
| | | * @param recordType 关联记录类型 |
| | | * @param recordId 关联记录id |
| | | */ |
| | | public void deleteStorageAttachmentsByApplicationAndRecordTypeAndRecordId(ApplicationTypeEnum application, RecordTypeEnum recordType, Long recordId) { |
| | | if (recordId == null || recordId <= 0) { |
| | | throw new RuntimeException("关联记录id不能为空"); |
| | |
| | | if (recordType == null) { |
| | | throw new RuntimeException("关联记录类型不能为空"); |
| | | } |
| | | deleteStorageBlobsByApplicationAndRecordTypeAndRecordId(application, recordType, recordId); |
| | | deleteStorageBlobsByApplicationAndRecordTypeAndRecordIds(application, recordType, Arrays.asList(recordId)); |
| | | storageAttachmentMapper.delete(new LambdaQueryWrapper<StorageAttachment>() |
| | | .eq(StorageAttachment::getRecordType, recordType.getType()) |
| | | .eq(StorageAttachment::getRecordId, recordId) |
| | |
| | | } |
| | | |
| | | /** |
| | | * 批量删除文件关联信息 attachment |
| | | * |
| | | * @param application 文件用途 |
| | | * @param recordType 关联记录类型 |
| | | * @param recordIds 关联记录id |
| | | */ |
| | | public void deleteStorageAttachmentsByApplicationAndRecordTypeAndRecordIds(ApplicationTypeEnum application, RecordTypeEnum recordType, List<Long> recordIds) { |
| | | if (recordIds == null || recordIds.isEmpty()) { |
| | | throw new RuntimeException("关联记录id不能为空"); |
| | | } |
| | | if (application == null) { |
| | | throw new RuntimeException("文件用途不能为空"); |
| | | } |
| | | if (recordType == null) { |
| | | throw new RuntimeException("关联记录类型不能为空"); |
| | | } |
| | | deleteStorageBlobsByApplicationAndRecordTypeAndRecordIds(application, recordType, recordIds); |
| | | storageAttachmentMapper.delete(new LambdaQueryWrapper<StorageAttachment>() |
| | | .eq(StorageAttachment::getRecordType, recordType.getType()) |
| | | .in(StorageAttachment::getRecordId, recordIds) |
| | | .eq(StorageAttachment::getApplication, application.getType())); |
| | | } |
| | | |
| | | /** |
| | | * 通过文件关联id获取文件信息 attachment |
| | | * |
| | | * @param storageAttachmentIds 文件id |