|
@@ -0,0 +1,40 @@
|
|
|
+package com.dayou.controller;
|
|
|
+
|
|
|
+
|
|
|
+import com.dayou.config.FileNetConfig;
|
|
|
+import com.zhuozhengsoft.pageoffice.FileSaver;
|
|
|
+import com.zhuozhengsoft.pageoffice.OpenModeType;
|
|
|
+import com.zhuozhengsoft.pageoffice.PageOfficeCtrl;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping(value = "/doc")
|
|
|
+public class PageOfficeController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FileNetConfig fileNetConfig;
|
|
|
+
|
|
|
+ //获取doc目录的磁盘路径
|
|
|
+ @RequestMapping(value="/openFile")
|
|
|
+ public String openFile(HttpServletRequest request, String fileName, String fileUrl) {
|
|
|
+ //file_id和file_name是为了展示如何使用参数,我们这里只用到了file_name
|
|
|
+ PageOfficeCtrl poCtrl = new PageOfficeCtrl(request);
|
|
|
+ //webOpen的第一个参数支持能够输出下载文件的Url相对地址或者文件在服务器上的磁盘路径两种方式
|
|
|
+ //查看详细,请在"https://www.pageoffice.cn/"搜索“PageOffice属性或方法中涉及到的URL路径或磁盘路径的说明”
|
|
|
+ poCtrl.webOpen("file://"+fileNetConfig.getBaseDir()+fileUrl, OpenModeType.docNormalEdit, "");
|
|
|
+ return poCtrl.getHtmlCode();//必须
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping("/saveFile")
|
|
|
+ public void saveFile(HttpServletRequest request, HttpServletResponse response, String fileName, String fileUrl) {
|
|
|
+ //file_id和file_name是为了展示如何使用参数,我们这里只用到了file_name
|
|
|
+ FileSaver fs = new FileSaver(request, response);
|
|
|
+ fs.saveToFile(fileNetConfig.getBaseDir() + fileUrl);
|
|
|
+ fs.close();
|
|
|
+ }
|
|
|
+}
|