| | |
| | | @Resource |
| | | private SystemStorageAttachmentService systemStorageAttachmentService; |
| | | |
| | | @Resource |
| | | private cn.iocoder.yudao.module.system.dal.mysql.storage.SystemStorageAttachmentMapper attachmentMapper; |
| | | |
| | | @Override |
| | | @org.springframework.transaction.annotation.Transactional(rollbackFor = Exception.class) |
| | | public void removeReference(String application, String recordType, Long recordId, Long blobId) { |
| | | attachmentMapper.delete(new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<cn.iocoder.yudao.module.system.dal.dataobject.storage.SystemStorageAttachmentDO>() |
| | | .eq(cn.iocoder.yudao.module.system.dal.dataobject.storage.SystemStorageAttachmentDO::getApplication, application) |
| | | .eq(cn.iocoder.yudao.module.system.dal.dataobject.storage.SystemStorageAttachmentDO::getRecordType, recordType) |
| | | .eq(cn.iocoder.yudao.module.system.dal.dataobject.storage.SystemStorageAttachmentDO::getRecordId, recordId) |
| | | .eq(cn.iocoder.yudao.module.system.dal.dataobject.storage.SystemStorageAttachmentDO::getStorageBlobId, blobId)); |
| | | } |
| | | |
| | | @Override |
| | | public void bindAttachments(String application, String recordType, Long recordId, List<Long> blobIds) { |
| | | if (blobIds == null || blobIds.isEmpty()) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void updateAttachments(String application, String recordType, Long recordId, List<Long> newBlobIds) { |
| | | if (newBlobIds == null) { |
| | | return; |
| | | } |
| | | if (newBlobIds.isEmpty()) { |
| | | // 清空所有附件 |
| | | systemStorageAttachmentService.deleteAttachmentsByApplicationAndRecordTypeAndRecordId( |
| | | application != null ? application : "file", recordType, recordId); |
| | | return; |
| | | } |
| | | // 全量替换:bindAttachments 内部先删后插,直接传入全部新 blobId 即可 |
| | | bindAttachments(application, recordType, recordId, newBlobIds); |
| | | } |
| | | |
| | | @Override |
| | | public List<StorageBlobRespDTO> listAttachments(String recordType, Long recordId) { |
| | | SystemStorageAttachmentListReqVO reqVO = new SystemStorageAttachmentListReqVO(); |
| | | reqVO.setApplication("file"); |
| | | reqVO.setRecordType(recordType); |
| | | reqVO.setRecordId(recordId); |
| | | List<SystemStorageBlobRespVO> list = systemStorageAttachmentService.listAttachments(reqVO); |