fix: 解决onlyoffice一进去就报错

This commit is contained in:
2024-10-12 16:11:25 +08:00
parent 1d74832ae0
commit 111db69735
@@ -49,6 +49,12 @@ public class OnlyOfficeController {
@Resource
private IOSSFileService ossFileService;
@ApiOperation(value = "|onlyOffice接收文件")
@PostMapping("/receiveFileBefore")
public void receiveFileBefore(HttpServletRequest request, HttpServletResponse response, String key, String fileNm, String standNo, String pid, String taskId, String standName) {
System.out.println("123");
}
@ApiOperation(value = "onlyOffice接收文件")
@PostMapping("/receiveFile")
public void receiveFileBefore(HttpServletRequest request, HttpServletResponse response, String fileId, String fileNm) throws IOException {
@@ -77,7 +83,9 @@ public class OnlyOfficeController {
log.info("**********onlyoffice接收文档接口获得结果body************" + body);
String downloadUri = (String) jsonObj.get("url");
int saved = 0;
if (StrUtil.isBlank(downloadUri)) {
writer.write("{\"error\":" + saved + "}");
return;
}
@@ -100,7 +108,7 @@ public class OnlyOfficeController {
ossFile.setOnlId(dbFile.getOnlId());
ossFileService.updateById(ossFile);
}
int saved = 0;
writer.write("{\"error\":" + saved + "}");
} catch (Exception e) {
log.error("onlyOffice接收文档接口异常", e);
@@ -149,7 +157,7 @@ public class OnlyOfficeController {
public void downLoadFileRoma(@RequestParam(name = "id") String fileId, HttpServletResponse response) {
OSSFile file = ossFileService.getById(fileId);
if (file == null) {
log.error("文件不存在");
log.error("文件不存在,文件Id: {}", fileId);
throw new RuntimeException("文件不存在");
}
response.reset();
@@ -205,9 +213,10 @@ public class OnlyOfficeController {
LambdaQueryWrapper<OSSFile> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(OSSFile::getOnlId, file.getOnlId());
wrapper.orderByDesc(OSSFile::getCreateTime);
wrapper.last("limit 10");
wrapper.last("limit 11");
List<OSSFile> ossFileList = ossFileService.list(wrapper);
if (!ossFileList.isEmpty()) {
ossFileList.remove(ossFileList.size() - 1);
for (OSSFile ossFile : ossFileList) {
Map<String, String> map = new HashMap<>();
map.put("id", ossFile.getId());