package com.ruoyi.basic.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
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 lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
/**
*
* 通用文件上传的附件信息 服务实现类
*
*
* @author ruoyi
* @since 2025-05-29
*/
@Service
@RequiredArgsConstructor
public class StorageAttachmentServiceImpl extends ServiceImpl implements StorageAttachmentService {
private final StorageBlobMapper storageBlobMapper;
private final StorageAttachmentMapper storageAttachmentMapper;
private final StorageBlobService storageBlobService;
@Override
public void saveStorageAttachment(List 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);
// }
}
@Override
public void saveStorageAttachment(List 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);
// }
}
@Override
public int deleteStorageAttachment(StorageAttachment storageAttachment) {
// 先删除明细表
// todo fileChange
// storageBlobService.deleteStorageBlobs(storageAttachment);
//
//
// return storageAttachmentMapper.delete(new LambdaQueryWrapper()
// .eq(StorageAttachment::getRecordId, storageAttachment.getRecordId())
// .eq(StorageAttachment::getRecordType, storageAttachment.getRecordType())
// .eq(StorageAttachment::getName, storageAttachment.getName()));
// }
return 0;
}
}