feat: 在线编辑根据id获取最新版本的文件信息
This commit is contained in:
+33
-15
@@ -13,11 +13,10 @@ import com.jero.modules.onlyoffice.service.IProcessFileService;
|
|||||||
import com.jero.modules.oss.entity.OSSFile;
|
import com.jero.modules.oss.entity.OSSFile;
|
||||||
import com.jero.modules.oss.service.IOSSFileService;
|
import com.jero.modules.oss.service.IOSSFileService;
|
||||||
import com.sini.com.spire.doc.Document;
|
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.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@@ -162,19 +161,19 @@ public class OnlyOfficeController {
|
|||||||
|
|
||||||
// 加载文档
|
// 加载文档
|
||||||
Document doc = new Document(inputStream);
|
Document doc = new Document(inputStream);
|
||||||
int i = 0;
|
// int i = 0;
|
||||||
try {
|
// try {
|
||||||
doc.getSections().get(0).getPageSetup().setPageNumberStyle(PageNumberStyle.Roman_Upper);
|
// doc.getSections().get(0).getPageSetup().setPageNumberStyle(PageNumberStyle.Roman_Upper);
|
||||||
for (; i < Integer.MAX_VALUE; i++) {
|
// for (; i < Integer.MAX_VALUE; i++) {
|
||||||
if (i == 1) {
|
// if (i == 1) {
|
||||||
doc.getSections().get(i).getPageSetup().setOrientation(PageOrientation.Portrait);//纵向
|
// doc.getSections().get(i).getPageSetup().setOrientation(PageOrientation.Portrait);//纵向
|
||||||
doc.getSections().get(i).getPageSetup().setPageNumberStyle(PageNumberStyle.Roman_Upper);
|
// doc.getSections().get(i).getPageSetup().setPageNumberStyle(PageNumberStyle.Roman_Upper);
|
||||||
}
|
// }
|
||||||
doc.getSections().get(i).getPageSetup().setOrientation(PageOrientation.Portrait);//纵向
|
// doc.getSections().get(i).getPageSetup().setOrientation(PageOrientation.Portrait);//纵向
|
||||||
}
|
// }
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
log.info("设置纵向页面,循环次数为:{}", i + 1);
|
// log.info("设置纵向页面,循环次数为:{}", i + 1);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 创建临时文件,系统会在适当的时候自动删除
|
// 创建临时文件,系统会在适当的时候自动删除
|
||||||
File tempFile = File.createTempFile(UUID.randomUUID().toString(), ".docx");
|
File tempFile = File.createTempFile(UUID.randomUUID().toString(), ".docx");
|
||||||
@@ -218,5 +217,24 @@ public class OnlyOfficeController {
|
|||||||
}
|
}
|
||||||
return Result.error("历史文件为空");
|
return Result.error("历史文件为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据Id获取文件信息
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "根据id获取最新版本的文件信息")
|
||||||
|
@GetMapping("/obtainLastFile")
|
||||||
|
public Result<String> obtainLastFile(String id) {
|
||||||
|
if (StringUtils.isBlank(id)) {
|
||||||
|
return Result.error("id不能为空!");
|
||||||
|
}
|
||||||
|
HashMap<String, String> map = new HashMap<>();
|
||||||
|
OSSFile firstVersion = ossFileService.getById(id);
|
||||||
|
LambdaQueryWrapper<OSSFile> 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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user