From 1ba4b22318fb90947b4f159c5dbf9050d0c02bce Mon Sep 17 00:00:00 2001 From: caihaohan Date: Sat, 12 Oct 2024 14:11:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=9C=A8=E7=BA=BF=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E6=A0=B9=E6=8D=AEid=E8=8E=B7=E5=8F=96=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E7=9A=84=E6=96=87=E4=BB=B6=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/OnlyOfficeController.java | 48 +++++++++++++------ 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/laws-modules/src/main/java/com/jero/modules/onlyoffice/controller/OnlyOfficeController.java b/laws-modules/src/main/java/com/jero/modules/onlyoffice/controller/OnlyOfficeController.java index 261214cd..15c4e536 100644 --- a/laws-modules/src/main/java/com/jero/modules/onlyoffice/controller/OnlyOfficeController.java +++ b/laws-modules/src/main/java/com/jero/modules/onlyoffice/controller/OnlyOfficeController.java @@ -13,11 +13,10 @@ import com.jero.modules.onlyoffice.service.IProcessFileService; import com.jero.modules.oss.entity.OSSFile; import com.jero.modules.oss.service.IOSSFileService; import com.sini.com.spire.doc.Document; -import com.sini.com.spire.doc.documents.PageNumberStyle; -import com.sini.com.spire.doc.documents.PageOrientation; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -162,19 +161,19 @@ public class OnlyOfficeController { // 加载文档 Document doc = new Document(inputStream); - int i = 0; - try { - doc.getSections().get(0).getPageSetup().setPageNumberStyle(PageNumberStyle.Roman_Upper); - for (; i < Integer.MAX_VALUE; i++) { - if (i == 1) { - doc.getSections().get(i).getPageSetup().setOrientation(PageOrientation.Portrait);//纵向 - doc.getSections().get(i).getPageSetup().setPageNumberStyle(PageNumberStyle.Roman_Upper); - } - doc.getSections().get(i).getPageSetup().setOrientation(PageOrientation.Portrait);//纵向 - } - } catch (Exception e) { - log.info("设置纵向页面,循环次数为:{}", i + 1); - } +// int i = 0; +// try { +// doc.getSections().get(0).getPageSetup().setPageNumberStyle(PageNumberStyle.Roman_Upper); +// for (; i < Integer.MAX_VALUE; i++) { +// if (i == 1) { +// doc.getSections().get(i).getPageSetup().setOrientation(PageOrientation.Portrait);//纵向 +// doc.getSections().get(i).getPageSetup().setPageNumberStyle(PageNumberStyle.Roman_Upper); +// } +// doc.getSections().get(i).getPageSetup().setOrientation(PageOrientation.Portrait);//纵向 +// } +// } catch (Exception e) { +// log.info("设置纵向页面,循环次数为:{}", i + 1); +// } // 创建临时文件,系统会在适当的时候自动删除 File tempFile = File.createTempFile(UUID.randomUUID().toString(), ".docx"); @@ -218,5 +217,24 @@ public class OnlyOfficeController { } return Result.error("历史文件为空"); } + + /** + * 根据Id获取文件信息 + */ + @ApiOperation(value = "根据id获取最新版本的文件信息") + @GetMapping("/obtainLastFile") + public Result obtainLastFile(String id) { + if (StringUtils.isBlank(id)) { + return Result.error("id不能为空!"); + } + HashMap map = new HashMap<>(); + OSSFile firstVersion = ossFileService.getById(id); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(OSSFile::getOnlId, firstVersion.getOnlId()); + wrapper.orderByDesc(OSSFile::getCreateTime); + wrapper.last("limit 1"); + OSSFile lastFile = ossFileService.getOne(wrapper); + return Result.OK(MessageUtils.getMessage(ResultCommon.OK), lastFile.getId()); + } }