mirror of
https://gitee.com/bookshelfplus/bookshelfplus
synced 2025-09-01 22:53:29 +08:00
去掉定时任务部分代码
This commit is contained in:
@@ -5,7 +5,6 @@ import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import plus.bookshelf.Service.Impl.ScheduleTaskServiceImpl;
|
||||
|
||||
@SpringBootApplication(scanBasePackages = {"plus.bookshelf"})
|
||||
@RestController
|
||||
@@ -21,9 +20,9 @@ public class App {
|
||||
|
||||
System.out.println("backend service started successfully.");
|
||||
|
||||
// 启动定时任务
|
||||
ScheduleTaskServiceImpl scheduleTaskService = new ScheduleTaskServiceImpl();
|
||||
scheduleTaskService.setExecutor();
|
||||
// // 启动定时任务
|
||||
// ScheduleTaskServiceImpl scheduleTaskService = new ScheduleTaskServiceImpl();
|
||||
// scheduleTaskService.setExecutor();
|
||||
}
|
||||
|
||||
@RequestMapping("/")
|
||||
|
@@ -50,10 +50,13 @@ public class FileController extends BaseController {
|
||||
@Autowired
|
||||
FileObjectServiceImpl fileObjectService;
|
||||
|
||||
// @Autowired
|
||||
// ScheduleTaskServiceImpl scheduleTaskService;
|
||||
|
||||
@ApiOperation(value = "查询文件列表", notes = "查询文件列表")
|
||||
@RequestMapping(value = "list", method = {RequestMethod.GET})
|
||||
@ResponseBody
|
||||
public CommonReturnType list(@RequestParam(value = "token", required = false) String token) throws InvocationTargetException, IllegalAccessException {
|
||||
public CommonReturnType list(@RequestParam(value = "token", required = false) String token) throws InvocationTargetException, IllegalAccessException, BusinessException {
|
||||
List<FileModel> fileModels = fileService.list(token);
|
||||
List<FileVO> fileVOS = new ArrayList<>();
|
||||
for (FileModel fileModel : fileModels) {
|
||||
@@ -163,4 +166,23 @@ public class FileController extends BaseController {
|
||||
map.put("urlGUID", urlGUID);
|
||||
return CommonReturnType.create(map);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "", notes = "客户端向腾讯云 COS 存储桶上传文件完毕")
|
||||
@RequestMapping(value = "/upload/finish-upload", method = {RequestMethod.POST}, consumes = {CONTENT_TYPE_FORMED})
|
||||
@ResponseBody
|
||||
public CommonReturnType cosFinishUpload(@RequestParam(value = "fileName") String fileName,
|
||||
@RequestParam(value = "urlGUID") String urlGUID) throws BusinessException {
|
||||
// // 从数据库中找到该任务
|
||||
// ScheduleTaskModel task = scheduleTaskService.findTaskByGuid(urlGUID);
|
||||
// if (task == null) {
|
||||
// throw new BusinessException(BusinessErrorCode.PARAMETER_VALIDATION_ERROR, "urlGUID 参数校验失败");
|
||||
// }
|
||||
//
|
||||
// // 完成这个任务
|
||||
// Boolean isSuccess = scheduleTaskService.doneScheduleTask(task.getId());
|
||||
|
||||
// TODO
|
||||
Boolean isSuccess = true;
|
||||
return CommonReturnType.create(isSuccess);
|
||||
}
|
||||
}
|
||||
|
@@ -27,6 +27,10 @@ public class FileServiceImpl implements FileService {
|
||||
@Autowired
|
||||
UserServiceImpl userService;
|
||||
|
||||
|
||||
// @Autowired
|
||||
// ScheduleTaskServiceImpl scheduleTaskService;
|
||||
|
||||
/**
|
||||
* 列出所有文件
|
||||
*
|
||||
@@ -55,4 +59,27 @@ public class FileServiceImpl implements FileService {
|
||||
BeanUtils.copyProperties(fileDO, fileModel);
|
||||
return fileModel;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 向数据库中添加一个 scheduleTask
|
||||
// *
|
||||
// * @param expireMinute
|
||||
// * @param fileName
|
||||
// * @param urlGUID
|
||||
// * @param userId
|
||||
// */
|
||||
// @Override
|
||||
// public void addScheduleTask(Integer expireMinute, String fileName, String urlGUID, Integer userId) {
|
||||
// ScheduleTaskModel scheduleTaskModel = new ScheduleTaskModel();
|
||||
// Calendar now = Calendar.getInstance();
|
||||
// scheduleTaskModel.setCreateTime(now.getTime());
|
||||
// now.add(Calendar.MILLISECOND, expireMinute * 60 * 1000);
|
||||
// scheduleTaskModel.setScheduleTime(now.getTime());
|
||||
// scheduleTaskModel.setAction(ScheduleTaskActionEnum.CHECK_FILE_IS_UPLOADED);
|
||||
// scheduleTaskModel.setData(fileName);
|
||||
// scheduleTaskModel.setTaskGuid(urlGUID);
|
||||
// scheduleTaskModel.setAssociatedUserId(userId);
|
||||
// scheduleTaskModel.setFailTime((byte) 0);
|
||||
// scheduleTaskService.insertScheduleTask(scheduleTaskModel);
|
||||
// }
|
||||
}
|
||||
|
@@ -7,6 +7,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import plus.bookshelf.Common.Enum.ScheduleTaskActionEnum;
|
||||
import plus.bookshelf.Common.Error.BusinessErrorCode;
|
||||
import plus.bookshelf.Common.Error.BusinessException;
|
||||
import plus.bookshelf.Common.FileManager.QCloudCosUtils;
|
||||
import plus.bookshelf.Config.QCloudCosConfig;
|
||||
import plus.bookshelf.Dao.DO.ScheduleTaskDO;
|
||||
import plus.bookshelf.Dao.Mapper.ScheduleTaskDOMapper;
|
||||
@@ -54,14 +55,30 @@ public class ScheduleTaskServiceImpl {
|
||||
// 检查上传文件后未收到客户端发来的上传完成消息的情况。
|
||||
// 如果系统里面没有记录,那么删除COS存储桶中用户上传的这个文件。
|
||||
|
||||
System.out.println("检查定时任务");
|
||||
|
||||
ScheduleTaskDO[] scheduleTaskDO = scheduleTaskDOMapper.selectTodoTask();
|
||||
|
||||
for (ScheduleTaskDO task : scheduleTaskDO) {
|
||||
ScheduleTaskModel scheduleTaskModel = convertToModel(task);
|
||||
switch (scheduleTaskModel.getAction()) {
|
||||
case CHECK_FILE_IS_UPLOADED:
|
||||
// TODO
|
||||
// TODO 系统中没有这个文件,而对象存储中有这个文件,那么删除对象存储中的文件
|
||||
// fileService.doScheduleTask(scheduleTaskModel);
|
||||
// 检查文件是否被上传
|
||||
QCloudCosUtils qCloudCosUtils = new QCloudCosUtils(qCloudCosConfig, cosPresignedUrlGenerateLogService);
|
||||
Boolean isExists = qCloudCosUtils.doesObjectExist(QCloudCosUtils.BOOK_SAVE_FOLDER, task.getData());
|
||||
if (isExists) {
|
||||
// 如果文件存在,则更新数据库中的状态
|
||||
// TODO
|
||||
System.out.println("文件已经上传,更新数据库中的状态");
|
||||
}
|
||||
|
||||
// 在数据库中设置为完成
|
||||
Boolean isDoneSuccess = doneScheduleTask(task.getId());
|
||||
if (!isDoneSuccess) {
|
||||
throw new BusinessException(BusinessErrorCode.UNKNOWN_ERROR, "系统错误!更新数据库中的状态失败");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new BusinessException(BusinessErrorCode.UNKNOWN_ERROR, "未知的定时任务类型");
|
@@ -11,5 +11,14 @@ public interface FileService {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<FileModel> list(String token) throws InvocationTargetException, IllegalAccessException;
|
||||
|
||||
// /**
|
||||
// * 向数据库中添加一个 scheduleTask
|
||||
// *
|
||||
// * @param expireMinute
|
||||
// * @param fileName
|
||||
// * @param urlGUID
|
||||
// * @param userId
|
||||
// */
|
||||
// void addScheduleTask(Integer expireMinute, String fileName, String urlGUID, Integer userId);
|
||||
}
|
||||
|
Reference in New Issue
Block a user