代码优化
This commit is contained in:
parent
bca2335d0c
commit
0360482610
@ -4,9 +4,14 @@ import com.github.tobato.fastdfs.service.AppendFileStorageClient;
|
|||||||
import com.qiwenshare.common.domain.UploadFile;
|
import com.qiwenshare.common.domain.UploadFile;
|
||||||
import com.qiwenshare.common.upload.product.AliyunOSSUploader;
|
import com.qiwenshare.common.upload.product.AliyunOSSUploader;
|
||||||
import com.qiwenshare.common.upload.Uploader;
|
import com.qiwenshare.common.upload.Uploader;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class AliyunOSSUploaderFactory implements UploaderFactory {
|
public class AliyunOSSUploaderFactory implements UploaderFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Uploader getUploader() {
|
public Uploader getUploader() {
|
||||||
return new AliyunOSSUploader();
|
return new AliyunOSSUploader();
|
||||||
@ -17,8 +22,4 @@ public class AliyunOSSUploaderFactory implements UploaderFactory {
|
|||||||
return new AliyunOSSUploader(uploadFile);
|
return new AliyunOSSUploader(uploadFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Uploader getUploader(UploadFile uploadFile, AppendFileStorageClient appendFileStorageClient) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,11 @@ import com.github.tobato.fastdfs.service.AppendFileStorageClient;
|
|||||||
import com.qiwenshare.common.domain.UploadFile;
|
import com.qiwenshare.common.domain.UploadFile;
|
||||||
import com.qiwenshare.common.upload.product.ChunkUploader;
|
import com.qiwenshare.common.upload.product.ChunkUploader;
|
||||||
import com.qiwenshare.common.upload.Uploader;
|
import com.qiwenshare.common.upload.Uploader;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class ChunkUploaderFactory implements UploaderFactory {
|
public class ChunkUploaderFactory implements UploaderFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -17,10 +21,5 @@ public class ChunkUploaderFactory implements UploaderFactory {
|
|||||||
return new ChunkUploader(uploadFile);
|
return new ChunkUploader(uploadFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Uploader getUploader(UploadFile uploadFile, AppendFileStorageClient appendFileStorageClient) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,15 @@ import com.github.tobato.fastdfs.service.AppendFileStorageClient;
|
|||||||
import com.qiwenshare.common.domain.UploadFile;
|
import com.qiwenshare.common.domain.UploadFile;
|
||||||
import com.qiwenshare.common.upload.Uploader;
|
import com.qiwenshare.common.upload.Uploader;
|
||||||
import com.qiwenshare.common.upload.product.FastDFSUploader;
|
import com.qiwenshare.common.upload.product.FastDFSUploader;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class FastDFSUploaderFactory implements UploaderFactory {
|
public class FastDFSUploaderFactory implements UploaderFactory {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
AppendFileStorageClient defaultAppendFileStorageClient;
|
||||||
@Override
|
@Override
|
||||||
public Uploader getUploader() {
|
public Uploader getUploader() {
|
||||||
return new FastDFSUploader();
|
return new FastDFSUploader();
|
||||||
@ -13,11 +20,7 @@ public class FastDFSUploaderFactory implements UploaderFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Uploader getUploader(UploadFile uploadFile) {
|
public Uploader getUploader(UploadFile uploadFile) {
|
||||||
return new FastDFSUploader(uploadFile);
|
return new FastDFSUploader(uploadFile, defaultAppendFileStorageClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Uploader getUploader(UploadFile uploadFile, AppendFileStorageClient appendFileStorageClient) {
|
|
||||||
return new FastDFSUploader(uploadFile, appendFileStorageClient);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,11 @@ import com.github.tobato.fastdfs.service.AppendFileStorageClient;
|
|||||||
import com.qiwenshare.common.domain.UploadFile;
|
import com.qiwenshare.common.domain.UploadFile;
|
||||||
import com.qiwenshare.common.upload.product.NormalUploader;
|
import com.qiwenshare.common.upload.product.NormalUploader;
|
||||||
import com.qiwenshare.common.upload.Uploader;
|
import com.qiwenshare.common.upload.Uploader;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class NormalUploaderFactory implements UploaderFactory {
|
public class NormalUploaderFactory implements UploaderFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -17,8 +21,4 @@ public class NormalUploaderFactory implements UploaderFactory {
|
|||||||
return new NormalUploader();
|
return new NormalUploader();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Uploader getUploader(UploadFile uploadFile, AppendFileStorageClient appendFileStorageClient) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -7,5 +7,4 @@ import com.qiwenshare.common.upload.Uploader;
|
|||||||
public interface UploaderFactory {
|
public interface UploaderFactory {
|
||||||
Uploader getUploader();
|
Uploader getUploader();
|
||||||
Uploader getUploader(UploadFile uploadFile);
|
Uploader getUploader(UploadFile uploadFile);
|
||||||
Uploader getUploader(UploadFile uploadFile, AppendFileStorageClient appendFileStorageClient);
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@ package com.qiwenshare.file;
|
|||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.context.annotation.FilterType;
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
@ -11,6 +13,11 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
//@EnableDiscoveryClient
|
//@EnableDiscoveryClient
|
||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
|
@ComponentScan(value = "com.qiwenshare", excludeFilters = @ComponentScan.Filter(
|
||||||
|
type = FilterType.ASSIGNABLE_TYPE,
|
||||||
|
classes = {
|
||||||
|
}
|
||||||
|
))
|
||||||
public class FileApplication {
|
public class FileApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
package com.qiwenshare.file.controller;
|
package com.qiwenshare.file.controller;
|
||||||
|
|
||||||
|
import com.aliyun.oss.OSS;
|
||||||
|
import com.aliyun.oss.model.OSSObject;
|
||||||
import com.qiwenshare.common.cbb.DateUtil;
|
import com.qiwenshare.common.cbb.DateUtil;
|
||||||
|
import com.qiwenshare.common.operation.FileOperation;
|
||||||
|
import com.qiwenshare.common.oss.AliyunOSSDownload;
|
||||||
import com.qiwenshare.common.util.FileUtil;
|
import com.qiwenshare.common.util.FileUtil;
|
||||||
import com.qiwenshare.common.cbb.RestResult;
|
import com.qiwenshare.common.cbb.RestResult;
|
||||||
|
import com.qiwenshare.common.util.PathUtil;
|
||||||
import com.qiwenshare.file.anno.MyLog;
|
import com.qiwenshare.file.anno.MyLog;
|
||||||
import com.qiwenshare.file.api.IFileService;
|
import com.qiwenshare.file.api.IFileService;
|
||||||
import com.qiwenshare.file.api.IFiletransferService;
|
import com.qiwenshare.file.api.IFiletransferService;
|
||||||
@ -13,6 +18,7 @@ import com.qiwenshare.file.domain.FileBean;
|
|||||||
import com.qiwenshare.file.domain.StorageBean;
|
import com.qiwenshare.file.domain.StorageBean;
|
||||||
import com.qiwenshare.file.domain.UserBean;
|
import com.qiwenshare.file.domain.UserBean;
|
||||||
import com.qiwenshare.file.domain.UserFile;
|
import com.qiwenshare.file.domain.UserFile;
|
||||||
|
import com.qiwenshare.file.dto.DownloadFileDTO;
|
||||||
import com.qiwenshare.file.dto.UploadFileDTO;
|
import com.qiwenshare.file.dto.UploadFileDTO;
|
||||||
import com.qiwenshare.file.vo.file.UploadFileVo;
|
import com.qiwenshare.file.vo.file.UploadFileVo;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
@ -22,6 +28,8 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.*;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -120,6 +128,86 @@ public class FiletransferController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载文件
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Operation(summary = "下载文件", description = "下载文件接口", tags = {"filetransfer"})
|
||||||
|
@MyLog(operation = "下载文件", module = CURRENT_MODULE)
|
||||||
|
@RequestMapping(value = "/downloadfile", method = RequestMethod.GET)
|
||||||
|
public String downloadFile(HttpServletResponse response, DownloadFileDTO downloadFileDTO) {
|
||||||
|
UserFile userFile = userFileService.getById(downloadFileDTO.getUserFileId());
|
||||||
|
|
||||||
|
String fileName = userFile.getFileName() + "." + userFile.getExtendName();
|
||||||
|
response.setContentType("application/force-download");// 设置强制下载不打开
|
||||||
|
response.addHeader("Content-Disposition", "attachment;fileName=" + fileName);// 设置文件名
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
BufferedInputStream bis = null;
|
||||||
|
FileBean fileBean = fileService.getById(userFile.getFileId());
|
||||||
|
if (fileBean.getIsOSS() != null && fileBean.getIsOSS() == 1) {
|
||||||
|
|
||||||
|
AliyunOSSDownload aliyunOSSDownload= new AliyunOSSDownload();
|
||||||
|
OSS ossClient = aliyunOSSDownload.createOSSClient(qiwenFileConfig.getAliyun().getOss());
|
||||||
|
OSSObject ossObject = ossClient.getObject(qiwenFileConfig.getAliyun().getOss().getBucketName(), fileBean.getTimeStampName());
|
||||||
|
InputStream inputStream = ossObject.getObjectContent();
|
||||||
|
try {
|
||||||
|
bis = new BufferedInputStream(inputStream);
|
||||||
|
OutputStream os = response.getOutputStream();
|
||||||
|
int i = bis.read(buffer);
|
||||||
|
while (i != -1) {
|
||||||
|
os.write(buffer, 0, i);
|
||||||
|
i = bis.read(buffer);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
if (bis != null) {
|
||||||
|
try {
|
||||||
|
bis.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
ossClient.shutdown();
|
||||||
|
} else {
|
||||||
|
//设置文件路径
|
||||||
|
File file = FileOperation.newFile(PathUtil.getStaticPath() + fileBean.getFileUrl());
|
||||||
|
if (file.exists()) {
|
||||||
|
|
||||||
|
|
||||||
|
FileInputStream fis = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
fis = new FileInputStream(file);
|
||||||
|
bis = new BufferedInputStream(fis);
|
||||||
|
OutputStream os = response.getOutputStream();
|
||||||
|
int i = bis.read(buffer);
|
||||||
|
while (i != -1) {
|
||||||
|
os.write(buffer, 0, i);
|
||||||
|
i = bis.read(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
if (bis != null) {
|
||||||
|
try {
|
||||||
|
bis.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "获取存储信息", description = "获取存储信息", tags = {"filetransfer"})
|
@Operation(summary = "获取存储信息", description = "获取存储信息", tags = {"filetransfer"})
|
||||||
@RequestMapping(value = "/getstorage", method = RequestMethod.GET)
|
@RequestMapping(value = "/getstorage", method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.qiwenshare.file.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(name = "下载文件DTO",required = true)
|
||||||
|
public class DownloadFileDTO {
|
||||||
|
private Long userFileId;
|
||||||
|
}
|
@ -15,6 +15,7 @@ import com.qiwenshare.common.upload.factory.AliyunOSSUploaderFactory;
|
|||||||
import com.qiwenshare.common.upload.factory.ChunkUploaderFactory;
|
import com.qiwenshare.common.upload.factory.ChunkUploaderFactory;
|
||||||
import com.qiwenshare.common.upload.Uploader;
|
import com.qiwenshare.common.upload.Uploader;
|
||||||
import com.qiwenshare.common.upload.factory.FastDFSUploaderFactory;
|
import com.qiwenshare.common.upload.factory.FastDFSUploaderFactory;
|
||||||
|
import com.qiwenshare.common.upload.factory.UploaderFactory;
|
||||||
import com.qiwenshare.file.api.IFiletransferService;
|
import com.qiwenshare.file.api.IFiletransferService;
|
||||||
|
|
||||||
import com.qiwenshare.common.domain.AliyunOSS;
|
import com.qiwenshare.common.domain.AliyunOSS;
|
||||||
@ -41,8 +42,13 @@ public class FiletransferService implements IFiletransferService {
|
|||||||
QiwenFileConfig qiwenFileConfig;
|
QiwenFileConfig qiwenFileConfig;
|
||||||
@Resource
|
@Resource
|
||||||
UserFileMapper userFileMapper;
|
UserFileMapper userFileMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
AppendFileStorageClient defaultAppendFileStorageClient;
|
UploaderFactory fastDFSUploaderFactory;
|
||||||
|
@Resource
|
||||||
|
UploaderFactory aliyunOSSUploaderFactory;
|
||||||
|
@Resource
|
||||||
|
UploaderFactory chunkUploaderFactory;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -61,11 +67,11 @@ public class FiletransferService implements IFiletransferService {
|
|||||||
uploadFile.setCurrentChunkSize(UploadFileDto.getCurrentChunkSize());
|
uploadFile.setCurrentChunkSize(UploadFileDto.getCurrentChunkSize());
|
||||||
synchronized (FiletransferService.class) {
|
synchronized (FiletransferService.class) {
|
||||||
if (oss.isEnabled()) {
|
if (oss.isEnabled()) {
|
||||||
uploader = new AliyunOSSUploaderFactory().getUploader(uploadFile);
|
uploader = aliyunOSSUploaderFactory.getUploader(uploadFile);
|
||||||
} else if ("FastFDS".equals(storyType)) {
|
} else if ("FastFDS".equals(storyType)) {
|
||||||
uploader = new FastDFSUploaderFactory().getUploader(uploadFile, defaultAppendFileStorageClient);
|
uploader = fastDFSUploaderFactory.getUploader(uploadFile);
|
||||||
} else {
|
} else {
|
||||||
uploader = new ChunkUploaderFactory().getUploader(uploadFile);
|
uploader = chunkUploaderFactory.getUploader(uploadFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,65 +59,65 @@ public class RecoveryFileService extends ServiceImpl<RecoveryFileMapper, Recove
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void restorefile() {
|
public void restorefile(String deleteBatchNum, String filePath, Long sessionUserId) {
|
||||||
// LambdaUpdateWrapper<UserFile> userFileLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
LambdaUpdateWrapper<UserFile> userFileLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||||
// userFileLambdaUpdateWrapper.set(UserFile::getDeleteFlag, 0)
|
userFileLambdaUpdateWrapper.set(UserFile::getDeleteFlag, 0)
|
||||||
// .set(UserFile::getDeleteBatchNum, "")
|
.set(UserFile::getDeleteBatchNum, "")
|
||||||
// .eq(UserFile::getDeleteBatchNum, restoreFileDto.getDeleteBatchNum());
|
.eq(UserFile::getDeleteBatchNum, deleteBatchNum);
|
||||||
// userFileService.update(userFileLambdaUpdateWrapper);
|
userFileMapper.update(null, userFileLambdaUpdateWrapper);
|
||||||
//
|
|
||||||
// String filePath = PathUtil.getParentPath(restoreFileDto.getFilePath());
|
String parentFilePath = PathUtil.getParentPath(filePath);
|
||||||
// while(filePath.indexOf("/") != -1) {
|
while(parentFilePath.indexOf("/") != -1) {
|
||||||
// String fileName = filePath.substring(filePath.lastIndexOf("/") + 1);
|
String fileName = parentFilePath.substring(parentFilePath.lastIndexOf("/") + 1);
|
||||||
// filePath = PathUtil.getParentPath(filePath);
|
parentFilePath = PathUtil.getParentPath(parentFilePath);
|
||||||
// LambdaQueryWrapper<UserFile> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<UserFile> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
// lambdaQueryWrapper.eq(UserFile::getFilePath, filePath + "/")
|
lambdaQueryWrapper.eq(UserFile::getFilePath, parentFilePath + "/")
|
||||||
// .eq(UserFile::getDeleteFlag, 0)
|
.eq(UserFile::getDeleteFlag, 0)
|
||||||
// .eq(UserFile::getUserId, sessionUserBean.getUserId());
|
.eq(UserFile::getUserId, sessionUserId);
|
||||||
// List<UserFile> userFileList = userFileService.list(lambdaQueryWrapper);
|
List<UserFile> userFileList = userFileMapper.selectList(lambdaQueryWrapper);
|
||||||
// if (userFileList.size() == 0) {
|
if (userFileList.size() == 0) {
|
||||||
// UserFile userFile = new UserFile();
|
UserFile userFile = new UserFile();
|
||||||
// userFile.setUserId(sessionUserBean.getUserId());
|
userFile.setUserId(sessionUserId);
|
||||||
// userFile.setFileName(fileName);
|
userFile.setFileName(fileName);
|
||||||
// userFile.setFilePath(filePath + "/");
|
userFile.setFilePath(parentFilePath + "/");
|
||||||
// userFile.setDeleteFlag(0);
|
userFile.setDeleteFlag(0);
|
||||||
// userFile.setIsDir(1);
|
userFile.setIsDir(1);
|
||||||
// userFile.setUploadTime(DateUtil.getCurrentTime());
|
userFile.setUploadTime(DateUtil.getCurrentTime());
|
||||||
//
|
|
||||||
// userFileService.save(userFile);
|
userFileMapper.insert(userFile);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// LambdaQueryWrapper<UserFile> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<UserFile> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
//
|
|
||||||
// lambdaQueryWrapper.select(UserFile::getFileName, UserFile::getFilePath)
|
lambdaQueryWrapper.select(UserFile::getFileName, UserFile::getFilePath)
|
||||||
// .likeRight(UserFile::getFilePath, restoreFileDto.getFilePath())
|
.likeRight(UserFile::getFilePath, filePath)
|
||||||
// .eq(UserFile::getIsDir, 1)
|
.eq(UserFile::getIsDir, 1)
|
||||||
// .eq(UserFile::getDeleteFlag, 0)
|
.eq(UserFile::getDeleteFlag, 0)
|
||||||
// .groupBy(UserFile::getFilePath, UserFile::getFileName)
|
.groupBy(UserFile::getFilePath, UserFile::getFileName)
|
||||||
// .having("count(fileName) >= 2");
|
.having("count(fileName) >= 2");
|
||||||
// List<UserFile> repeatList = userFileService.list(lambdaQueryWrapper);
|
List<UserFile> repeatList = userFileMapper.selectList(lambdaQueryWrapper);
|
||||||
//
|
|
||||||
// for (UserFile userFile : repeatList) {
|
for (UserFile userFile : repeatList) {
|
||||||
// LambdaQueryWrapper<UserFile> lambdaQueryWrapper1 = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<UserFile> lambdaQueryWrapper1 = new LambdaQueryWrapper<>();
|
||||||
// lambdaQueryWrapper1.eq(UserFile::getFilePath, userFile.getFilePath())
|
lambdaQueryWrapper1.eq(UserFile::getFilePath, userFile.getFilePath())
|
||||||
// .eq(UserFile::getFileName, userFile.getFileName())
|
.eq(UserFile::getFileName, userFile.getFileName())
|
||||||
// .eq(UserFile::getDeleteFlag, "0");
|
.eq(UserFile::getDeleteFlag, "0");
|
||||||
// List<UserFile> userFiles = userFileService.list(lambdaQueryWrapper1);
|
List<UserFile> userFiles = userFileMapper.selectList(lambdaQueryWrapper1);
|
||||||
// log.info("重复的文件:" + JSON.toJSONString(userFiles));
|
log.info("重复的文件:" + JSON.toJSONString(userFiles));
|
||||||
// for (int i = 0; i < userFiles.size() - 1; i ++) {
|
for (int i = 0; i < userFiles.size() - 1; i ++) {
|
||||||
// log.info("删除文件:" + JSON.toJSONString(userFiles.get(i)));
|
log.info("删除文件:" + JSON.toJSONString(userFiles.get(i)));
|
||||||
// userFileService.removeById(userFiles.get(i).getUserFileId());
|
userFileMapper.deleteById(userFiles.get(i).getUserFileId());
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// log.info(JSON.toJSONString(repeatList));
|
log.info(JSON.toJSONString(repeatList));
|
||||||
//
|
|
||||||
// LambdaQueryWrapper<RecoveryFile> recoveryFileServiceLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<RecoveryFile> recoveryFileServiceLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
// recoveryFileServiceLambdaQueryWrapper.eq(RecoveryFile::getDeleteBatchNum, restoreFileDto.getDeleteBatchNum());
|
recoveryFileServiceLambdaQueryWrapper.eq(RecoveryFile::getDeleteBatchNum, deleteBatchNum);
|
||||||
// recoveryFileService.remove(recoveryFileServiceLambdaQueryWrapper);
|
recoveryFileMapper.delete(recoveryFileServiceLambdaQueryWrapper);
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user