【上传MINIO文件时,逻辑删除原有旧数据】
This commit is contained in:
parent
e7b817c2d4
commit
5a27cc414e
@ -13,9 +13,11 @@ import com.github.pagehelper.PageHelper;
|
||||
import io.minio.http.Method;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@ -46,6 +48,14 @@ public class MinioServiceImpl implements MinioService {
|
||||
|
||||
@Override
|
||||
public void saveFileInfo(AccountVO user, MinioFileInfo minioFileInfo) {
|
||||
// 检查数据库中是否已存在记录
|
||||
MinioFileInfoExample example = new MinioFileInfoExample();
|
||||
MinioFileInfoExample.Criteria criteria = example.createCriteria().andStatusEqualTo(1);
|
||||
criteria.andDirectoryEqualTo(minioFileInfo.getDirectory()).andFilenameEqualTo(minioFileInfo.getFileName());
|
||||
List<MinioFileInfo> oldMinioFile = this.minioFileInfoDao.selectByExample(example);
|
||||
if (!CollectionUtils.isEmpty(oldMinioFile)) { // 删除旧数据
|
||||
oldMinioFile.forEach(m -> this.delete(m.getId()));
|
||||
}
|
||||
minioFileInfo.setCreator(user.getId());
|
||||
minioFileInfo.setCreateTime(LocalDateTime.now());
|
||||
minioFileInfo.setStatus(1);
|
||||
|
Loading…
Reference in New Issue
Block a user