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