| | |
| | | package com.ruoyi.basic.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.dto.StorageAttachmentDTO; |
| | | import com.ruoyi.basic.dto.StorageAttachmentVO; |
| | | import com.ruoyi.basic.dto.StorageBlobDTO; |
| | | import com.ruoyi.basic.enums.ApplicationTypeEnum; |
| | | import com.ruoyi.basic.enums.RecordTypeEnum; |
| | | import com.ruoyi.basic.mapper.StorageAttachmentMapper; |
| | | import com.ruoyi.basic.mapper.StorageBlobMapper; |
| | | import com.ruoyi.basic.pojo.StorageAttachment; |
| | | import com.ruoyi.basic.service.StorageAttachmentService; |
| | | import com.ruoyi.basic.service.StorageBlobService; |
| | | import com.ruoyi.common.constant.StorageAttachmentConstants; |
| | | import com.ruoyi.common.enums.StorageAttachmentRecordType; |
| | | import com.ruoyi.basic.utils.FileUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | private final StorageAttachmentMapper storageAttachmentMapper; |
| | | |
| | | private final StorageBlobService storageBlobService; |
| | | |
| | | private final FileUtil fileUtil; |
| | | |
| | | @Override |
| | | public void saveStorageAttachment(List<StorageAttachment> attachments, Long recordId, StorageAttachmentRecordType recordType, StorageAttachmentConstants fileType) { |
| | | // 删除旧图 |
| | | // todo fileChange |
| | | // deleteStorageAttachment(new StorageAttachment(fileType.toString(), (long) recordType.ordinal(), recordId)); |
| | | // for (StorageAttachment attachment : attachments) { |
| | | // // 获取关联记录 |
| | | // StorageBlob storageBlob = attachment.getStorageBlobDTO(); |
| | | // attachment.setName(fileType.toString()); |
| | | // attachment.setRecordType((long) recordType.ordinal()); |
| | | // attachment.setRecordId(recordId); |
| | | // attachment.setStorageBlobId(storageBlob.getId()); |
| | | // storageAttachmentMapper.insert(attachment); |
| | | // } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void saveStorageAttachment(List<StorageBlobDTO> storageBlobDTOS, Long recordId, String recordType, String fileType) { |
| | | fileUtil.saveStorageAttachment(ApplicationTypeEnum.getByType(fileType), RecordTypeEnum.getByType(recordType), recordId, storageBlobDTOS); |
| | | } |
| | | |
| | | @Override |
| | | public void saveStorageAttachment(List<StorageAttachment> attachments, Long recordId, StorageAttachmentRecordType recordType, String fileType) { |
| | | // 删除旧图 |
| | | // deleteStorageAttachment(new StorageAttachment(fileType, (long) recordType.ordinal(), recordId)); |
| | | // todo fileChange |
| | | // for (StorageAttachment attachment : attachments) { |
| | | // // 获取关联记录 |
| | | // StorageBlob storageBlob = attachment.getStorageBlobDTO(); |
| | | // attachment.setName(fileType); |
| | | // attachment.setRecordType((long) recordType.ordinal()); |
| | | // attachment.setRecordId(recordId); |
| | | // attachment.setStorageBlobId(storageBlob.getId()); |
| | | // storageAttachmentMapper.insert(attachment); |
| | | // } |
| | | |
| | | public IPage<StorageAttachmentVO> listPage(Page page, StorageAttachmentDTO storageAttachmentDTO) { |
| | | return fileUtil.getStorageAttachmentVosPageListByApplicationAndRecordTypeAndRecordId(page, storageAttachmentDTO); |
| | | } |
| | | |
| | | @Override |
| | |
| | | // } |
| | | return 0; |
| | | } |
| | | |
| | | @Override |
| | | public int batchDeleteStorageAttachment(List<Long> ids) { |
| | | fileUtil.deleteStorageAttachmentsByStorageAttachmentIds(ids); |
| | | return 1; |
| | | } |
| | | } |