1
0
mirror of https://gitee.com/bookshelfplus/bookshelfplus synced 2025-09-01 22:53:29 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

新增”添加网盘链接“功能

This commit is contained in:
2022-04-23 22:14:59 +08:00
parent 89a93009d5
commit c95a581aaf
14 changed files with 2841 additions and 826 deletions

View File

@@ -171,7 +171,7 @@ public class BookController extends BaseController {
Integer affectRows = 0;
if (bookId == null || bookId == 0) {
// 新增图书
isDelete = false;
// isDelete = false;
affectRows = bookService.addBook(bookModel);
} else {
//修改图书

View File

@@ -18,11 +18,10 @@ import plus.bookshelf.Common.Error.BusinessException;
import plus.bookshelf.Common.FileManager.QCloudCosUtils;
import plus.bookshelf.Common.Response.CommonReturnType;
import plus.bookshelf.Config.QCloudCosConfig;
import plus.bookshelf.Controller.VO.BookVO;
import plus.bookshelf.Controller.VO.FileObjectVO;
import plus.bookshelf.Service.Impl.*;
import plus.bookshelf.Service.Model.FailureFeedbackModel;
import plus.bookshelf.Service.Model.FileObjectModel;
import plus.bookshelf.Service.Model.UserModel;
import plus.bookshelf.Service.Model.*;
import plus.bookshelf.Service.Service.CosPresignedUrlGenerateLogService;
import java.lang.reflect.InvocationTargetException;
@@ -55,6 +54,45 @@ public class FileObjectController extends BaseController {
VisitorFingerprintLogServiceImpl visitorFingerprintLogService;
@ApiOperation(value = "【管理员】添加/修改文件对象", notes = "管理员在后台添加/修改文件对象fileObjectId 传 0 或 null 或 不传 即为添加)")
@RequestMapping(value = "detail", method = {RequestMethod.POST}, consumes = {CONTENT_TYPE_FORMED})
@ResponseBody
public CommonReturnType detail(@RequestParam(value = "token", required = false) String token,
@RequestParam(required = false, value = "id") Integer fileObjectId,
@RequestParam(required = false, value = "filePath") String filePath,
@RequestParam(required = false, value = "fileId") Integer fileId,
@RequestParam(required = false, value = "filePwd") String filePwd,
@RequestParam(required = false, value = "fileShareCode") String fileShareCode,
@RequestParam(required = false, value = "storageMedium") String storageMedium) throws BusinessException, InvocationTargetException, IllegalAccessException {
// 已经在 getUserByToken 方法中判断了 token 为空、不合法;用户不存在情况,此处无需再判断
UserModel userModel = userService.getUserByToken(redisTemplate, token);
FileObjectModel fileObjectModel = new FileObjectModel();
fileObjectModel.setFilePath(filePath);
fileObjectModel.setFileId(fileId);
fileObjectModel.setFilePwd(filePwd);
fileObjectModel.setFileShareCode(fileShareCode);
fileObjectModel.setStorageMedium(storageMedium);
Boolean isSuccess;
if (fileObjectId == null || fileObjectId == 0) {
// 新增文件对象
fileObjectModel.setUploadStatus("SUCCESS");
isSuccess = fileObjectService.addFileObject(fileObjectModel);
} else {
//修改文件对象
fileObjectModel.setId(fileObjectId);
isSuccess = fileObjectService.modifyFileObject(fileObjectModel);
}
if (isSuccess) {
return CommonReturnType.create("success");
} else {
return CommonReturnType.create("failed");
}
}
@ApiOperation(value = "链接失效反馈", notes = "查询文件列表")
@RequestMapping(value = "FailureFeedback", method = {RequestMethod.POST}, consumes = {CONTENT_TYPE_FORMED})
@ResponseBody
@@ -125,6 +163,19 @@ public class FileObjectController extends BaseController {
return CommonReturnType.create(fileObjectVOS);
}
@ApiOperation(value = "获取文件对象信息", notes = "获取文件对象信息")
@RequestMapping(value = "get", method = {RequestMethod.GET})
@ResponseBody
public CommonReturnType get(@RequestParam(value = "id") Integer id) throws InvocationTargetException, IllegalAccessException {
if (id == null) {
return null;
}
FileObjectModel fileObjectModel = fileObjectService.getFileObjectById(id);
FileObjectVO fileObjectVO = convertFileObjectVOFromModel(fileObjectModel);
return CommonReturnType.create(fileObjectVO);
}
@ApiOperation(value = "【管理员】更新文件对象上传状态", notes = "重新从 COS 对象存储中获取文件对象上传状态")
@RequestMapping(value = "refreshFileObjectStatus", method = {RequestMethod.POST}, consumes = {CONTENT_TYPE_FORMED})
@ResponseBody
@@ -378,7 +429,7 @@ public class FileObjectController extends BaseController {
BeanUtils.copyProperties(fileObjectModel, fileObjectVO);
try {
// 尝试将 FileStorageMedium 转为中文,如果没有成功,那么就保留英文
fileObjectVO.setStorageMedium(FileStorageMediumEnum.valueOf(fileObjectModel.getStorageMedium()).getStorageMediumDisplayName());
fileObjectVO.setStorageMediumForDisplay(FileStorageMediumEnum.valueOf(fileObjectModel.getStorageMedium()).getStorageMediumDisplayName());
} catch (Exception e) {
}
return fileObjectVO;

View File

@@ -15,6 +15,7 @@ public class FileObjectVO {
String uploadStatus;
// 文件存储介质类型
String storageMediumForDisplay;
String storageMedium;
// 文件地址

View File

@@ -20,7 +20,6 @@ import plus.bookshelf.Service.Service.FileObjectService;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@Service
@@ -107,6 +106,26 @@ public class FileObjectServiceImpl implements FileObjectService {
return affectRows > 0;
}
/**
* 修改文件对象
* 返回是否修改成功
*
* @param fileObjectModel
* @return
* @throws InvocationTargetException
* @throws IllegalAccessException
*/
@Override
public Boolean modifyFileObject(FileObjectModel fileObjectModel) {
FileObjectDO fileObjectDO = convertFromFileObjectModel(fileObjectModel);
Integer id = fileObjectDO.getId();
if (id == 0) {
return false;
}
int affectRows = fileObjectDOMapper.updateByPrimaryKeySelective(fileObjectDO);
return affectRows > 0;
}
private FileObjectDO convertFromFileObjectModel(FileObjectModel fileObjectModel) {
if (fileObjectModel == null) {
return null;

View File

@@ -38,6 +38,14 @@ public interface FileObjectService {
*/
Boolean addFileObject(FileObjectModel fileObjectModel) throws InvocationTargetException, IllegalAccessException;
/**
* 修改文件对象
*
* @param fileObjectModel
* @return
*/
Boolean modifyFileObject(FileObjectModel fileObjectModel);
/**
* 向数据库中插入文件信息
*