package com.ruoyi.basic.service.impl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.ruoyi.basic.dto.StorageAttachmentDTO;
|
import com.ruoyi.basic.dto.StorageBlobVO;
|
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.basic.utils.FileUtil;
|
import lombok.RequiredArgsConstructor;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.util.List;
|
|
/**
|
* <p>
|
* 通用文件上传的附件信息 服务实现类
|
* </p>
|
*
|
* @author ruoyi
|
* @since 2025-05-29
|
*/
|
@Service
|
@RequiredArgsConstructor
|
public class StorageAttachmentServiceImpl extends ServiceImpl<StorageAttachmentMapper, StorageAttachment> implements StorageAttachmentService {
|
private final StorageBlobMapper storageBlobMapper;
|
|
private final StorageAttachmentMapper storageAttachmentMapper;
|
|
private final StorageBlobService storageBlobService;
|
private final FileUtil fileUtil;
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void saveStorageAttachment(StorageAttachmentDTO storageAttachmentDTO) {
|
fileUtil.saveStorageAttachmentByRecordTypeAndRecordId(storageAttachmentDTO.getApplication(), RecordTypeEnum.getByType(storageAttachmentDTO.getRecordType()), storageAttachmentDTO.getRecordId(), storageAttachmentDTO.getStorageBlobDTOs());
|
}
|
|
@Override
|
public List<StorageBlobVO> list(StorageAttachmentDTO storageAttachmentDTO) {
|
return fileUtil.getStorageBlobVOsByApplicationAndRecordTypeAndRecordId(storageAttachmentDTO);
|
}
|
|
@Override
|
public int deleteStorageAttachment(StorageAttachment storageAttachment) {
|
// 先删除明细表
|
// todo fileChange
|
// storageBlobService.deleteStorageBlobs(storageAttachment);
|
//
|
//
|
// return storageAttachmentMapper.delete(new LambdaQueryWrapper<StorageAttachment>()
|
// .eq(StorageAttachment::getRecordId, storageAttachment.getRecordId())
|
// .eq(StorageAttachment::getRecordType, storageAttachment.getRecordType())
|
// .eq(StorageAttachment::getName, storageAttachment.getName()));
|
// }
|
return 0;
|
}
|
|
@Override
|
public int batchDeleteStorageAttachment(List<Long> ids) {
|
fileUtil.deleteStorageAttachmentsByStorageAttachmentIds(ids);
|
return 1;
|
}
|
}
|