Selaa lähdekoodia

Merge branch 'bgy' of SH-Arbitrate/OnlyOffice-Backend into dev

bgy 2 vuotta sitten
vanhempi
commit
ce32f7edfa

+ 11
- 5
src/main/java/com/oo/demo/controller/OnlyOfficeController.java Näytä tiedosto

236
      * 6 - 正在编辑文档,但保存当前文档状态
236
      * 6 - 正在编辑文档,但保存当前文档状态
237
      * 7 - 强制保存文档时发生错误
237
      * 7 - 强制保存文档时发生错误
238
      */
238
      */
239
-    @RequestMapping("/onlyOffice/save")
239
+    @RequestMapping("/onlyOffice/save/{fileId}")
240
     @ResponseBody
240
     @ResponseBody
241
-    public void saveFile(HttpServletRequest request, HttpServletResponse response) {
241
+    public void saveFile(HttpServletRequest request, HttpServletResponse response,@PathVariable(required = false) String fileId) {
242
         PrintWriter writer = null;
242
         PrintWriter writer = null;
243
         try {
243
         try {
244
             writer = response.getWriter();
244
             writer = response.getWriter();
246
             Scanner scanner = new Scanner(request.getInputStream()).useDelimiter("\\A");
246
             Scanner scanner = new Scanner(request.getInputStream()).useDelimiter("\\A");
247
             String body = scanner.hasNext() ? scanner.next() : "";
247
             String body = scanner.hasNext() ? scanner.next() : "";
248
             JSONObject jsonObject = JSONObject.parseObject(body);
248
             JSONObject jsonObject = JSONObject.parseObject(body);
249
+            if(fileId!=null){
250
+                jsonObject.put("fileId",fileId);
251
+            }else{
252
+                jsonObject.put("fileId","");
253
+            }
249
             log.info("{}", jsonObject);
254
             log.info("{}", jsonObject);
250
             WebsocketResult result = fileService.documentSave(jsonObject);
255
             WebsocketResult result = fileService.documentSave(jsonObject);
251
             /*
256
             /*
258
                 userId = userSession.getId();
263
                 userId = userSession.getId();
259
             }
264
             }
260
             WebSocketServer.sendInfo(JSON.toJSONString(result.getOnFile()), userId);
265
             WebSocketServer.sendInfo(JSON.toJSONString(result.getOnFile()), userId);
261
-            if (Objects.nonNull(writer)) {
262
-                writer.write("{\"error\":0}");
263
-            }
266
+//            if (Objects.nonNull(writer)) {
267
+//                writer.write("{\"error\":0}");
268
+//            }
269
+            writer.write("{\"error\":0}");
264
         } catch (Exception e) {
270
         } catch (Exception e) {
265
             e.printStackTrace();
271
             e.printStackTrace();
266
             log.info("报错信息" + e.getMessage());
272
             log.info("报错信息" + e.getMessage());

+ 14
- 2
src/main/java/com/oo/demo/service/DemoService.java Näytä tiedosto

36
 
36
 
37
     }
37
     }
38
 
38
 
39
+    /**
40
+     * 存储onlyoffice文件信息
41
+     * @param map     文件元信息
42
+     * @param file    文件
43
+     * @param changes 文件变动信息
44
+     * @param fileId 文件id
45
+     * @return
46
+     */
39
     @Override
47
     @Override
40
-    public Map<String, Object> save(Map<String, Object> map, byte[] file, byte[] changes, String key) {
41
-        String fileId = "";
48
+    public Map<String, Object> save(Map<String, Object> map, byte[] file, byte[] changes, String fileId) {
42
         try {
49
         try {
50
+        if(fileId!=null&&fileId!=""){
51
+            onFileService.updateFileByFileId(file, map.get("fileType").toString(),fileId);
52
+        }else{
53
+            fileId = "";
43
             fileId = onFileService.saveFile(file, map.get("fileType").toString());
54
             fileId = onFileService.saveFile(file, map.get("fileType").toString());
55
+        }
44
         } catch (Exception e) {
56
         } catch (Exception e) {
45
             e.printStackTrace();
57
             e.printStackTrace();
46
         }
58
         }

+ 29
- 2
src/main/java/com/oo/demo/service/FileService.java Näytä tiedosto

52
     public WebsocketResult documentSave(JSONObject jsonObject) {
52
     public WebsocketResult documentSave(JSONObject jsonObject) {
53
         WebsocketResult result = new WebsocketResult();
53
         WebsocketResult result = new WebsocketResult();
54
         String key = "";
54
         String key = "";
55
+        String fileId = jsonObject.getString("fileId");
55
         try {
56
         try {
56
             int status = jsonObject.getIntValue("status");
57
             int status = jsonObject.getIntValue("status");
57
             log.info("status[{}]", status);
58
             log.info("status[{}]", status);
69
                 key = jsonObject.getString("key");
70
                 key = jsonObject.getString("key");
70
                 log.info("key:" + JSON.toJSONString(key));
71
                 log.info("key:" + JSON.toJSONString(key));
71
                 //文件id
72
                 //文件id
72
-                String fileId = onlyServiceAPI.getFileId(key);
73
+                Boolean isexistid = false;
74
+                if (fileId != null && !"".equals(fileId)) {
75
+                    isexistid = true;
76
+                }
77
+                if (!isexistid) {
78
+                    fileId = onlyServiceAPI.getFileId(key);
79
+                }
73
                 log.info("fileId:" + JSON.toJSONString(fileId));
80
                 log.info("fileId:" + JSON.toJSONString(fileId));
74
                 if (fileId != null && !"".equals(fileId)) {
81
                 if (fileId != null && !"".equals(fileId)) {
75
                     //查询之前FileId对应的文件信息
82
                     //查询之前FileId对应的文件信息
93
                 //处理文件的保存
100
                 //处理文件的保存
94
                 OnFile file = onlyServiceAPI.handlerStatus(jsonObject);
101
                 OnFile file = onlyServiceAPI.handlerStatus(jsonObject);
95
                 //查询相同案件最新版本的文件信息
102
                 //查询相同案件最新版本的文件信息
96
-                file = getNewFileInofoByCaseId(file.getCaseId());
103
+                if (fileId != null && !"".equals(fileId)) {
104
+                    file = getNewFileInofoByFileId(fileId);
105
+                } else {
106
+                    file = getNewFileInofoByCaseId(file.getCaseId());
107
+                }
97
                 result = WebsocketResult.builder().onFile(file).userId(SecurityUtils.getUserSession().getId()).build();
108
                 result = WebsocketResult.builder().onFile(file).userId(SecurityUtils.getUserSession().getId()).build();
98
                 log.info("处理文件的保存:" + JSON.toJSONString(jsonObject));
109
                 log.info("处理文件的保存:" + JSON.toJSONString(jsonObject));
99
                 log.info("保存文件结束");
110
                 log.info("保存文件结束");
101
                 return result;
112
                 return result;
102
             } else if (0 == status || 2 == status || 4 == status) {
113
             } else if (0 == status || 2 == status || 4 == status) {
103
                 onlyServiceAPI.close(jsonObject);
114
                 onlyServiceAPI.close(jsonObject);
115
+                log.info("文件关闭====",status);
104
             } else if (3 == status || 7 == status) {
116
             } else if (3 == status || 7 == status) {
105
                 //保存文档错误
117
                 //保存文档错误
106
                 onlyServiceAPI.close(jsonObject);
118
                 onlyServiceAPI.close(jsonObject);
119
+                log.info("保存文档错误====",status);
107
             } else if (1 == status) {
120
             } else if (1 == status) {
121
+                log.info("文件正在编辑====",status);
108
                 //文件服务的回调  获取key判断当前文档有多少人在这使用
122
                 //文件服务的回调  获取key判断当前文档有多少人在这使用
109
                 List<Map> actions = JSONObject.parseArray(jsonObject.getString("actions"), Map.class);
123
                 List<Map> actions = JSONObject.parseArray(jsonObject.getString("actions"), Map.class);
110
                 if ((Integer) actions.get(0).get("type") == 1) {
124
                 if ((Integer) actions.get(0).get("type") == 1) {
145
         log.info("caseId:" + caseId + ":fileinfo:" + JSON.toJSONString(file));
159
         log.info("caseId:" + caseId + ":fileinfo:" + JSON.toJSONString(file));
146
         return file;
160
         return file;
147
     }
161
     }
162
+
163
+    /**
164
+     * 根据文件的fileid查询文件信息
165
+     */
166
+    private OnFile getNewFileInofoByFileId(String fileId) {
167
+        OnFile file = onFileMapper.selectById(fileId);
168
+        if (file != null) {
169
+            log.info("caseId:" + file.getCaseId() + ":fileinfo:" + JSON.toJSONString(file));
170
+        } else {
171
+            log.info("根据文件id未查询到文件信息");
172
+        }
173
+        return file;
174
+    }
148
 }
175
 }

+ 15
- 1
src/main/java/com/oo/demo/service/OnFileService.java Näytä tiedosto

4
 import com.oo.demo.entity.OnFile;
4
 import com.oo.demo.entity.OnFile;
5
 
5
 
6
 import javax.servlet.http.HttpServletResponse;
6
 import javax.servlet.http.HttpServletResponse;
7
-import java.io.File;
8
 
7
 
9
 
8
 
10
 public interface OnFileService extends IService<OnFile> {
9
 public interface OnFileService extends IService<OnFile> {
11
     /**
10
     /**
12
      * 保存onlyoffice文件
11
      * 保存onlyoffice文件
12
+     *
13
      * @param bytes
13
      * @param bytes
14
      * @param fileType
14
      * @param fileType
15
      * @return
15
      * @return
17
      */
17
      */
18
     String saveFile(byte[] bytes, String fileType) throws Exception;
18
     String saveFile(byte[] bytes, String fileType) throws Exception;
19
 
19
 
20
+    /**
21
+     * 通过文件id更新onlyoffice文件
22
+     *
23
+     * @param bytes
24
+     * @param fileType
25
+     * @param fileId
26
+     * @return
27
+     * @throws Exception
28
+     */
29
+    String updateFileByFileId(byte[] bytes, String fileType, String fileId) throws Exception;
30
+
20
     /**
31
     /**
21
      * 删除onlyoffice文件
32
      * 删除onlyoffice文件
33
+     *
22
      * @param id
34
      * @param id
23
      */
35
      */
24
     void removeFile(String id);
36
     void removeFile(String id);
25
 
37
 
26
     /**
38
     /**
27
      * 下载onlyoffice文件
39
      * 下载onlyoffice文件
40
+     *
28
      * @param id
41
      * @param id
29
      * @param isBrowser
42
      * @param isBrowser
30
      * @param response
43
      * @param response
33
 
46
 
34
     /**
47
     /**
35
      * 根据文件id查找文件信息
48
      * 根据文件id查找文件信息
49
+     *
36
      * @param id
50
      * @param id
37
      * @return
51
      * @return
38
      */
52
      */

+ 37
- 0
src/main/java/com/oo/demo/service/OnFileServiceImpl.java Näytä tiedosto

56
         removeById(id);
56
         removeById(id);
57
     }
57
     }
58
 
58
 
59
+    /**
60
+     * 新增文件信息到数据库
61
+     *
62
+     * @param bytes
63
+     * @param fileType
64
+     * @return
65
+     * @throws Exception
66
+     */
59
     public String saveFile(byte[] bytes, String fileType) throws Exception {
67
     public String saveFile(byte[] bytes, String fileType) throws Exception {
60
 
68
 
61
         String fileId = IdUtil.simpleUUID();
69
         String fileId = IdUtil.simpleUUID();
70
         }
78
         }
71
         return fileId;
79
         return fileId;
72
     }
80
     }
81
+
82
+    /**
83
+     * 更新文件信息到数据库
84
+     *
85
+     * @param bytes
86
+     * @param fileType
87
+     * @param fileId
88
+     * @return
89
+     * @throws Exception
90
+     */
91
+    public String updateFileByFileId(byte[] bytes, String fileType, String fileId) throws Exception {
92
+        Boolean ishaveid = false;
93
+        if (fileId != null && fileId != "") {
94
+            ishaveid = true;
95
+        }
96
+        if (!ishaveid) {
97
+            fileId = IdUtil.simpleUUID();
98
+        }
99
+        File file = new File(path + "/" + fileId + "." + fileType);
100
+        File parentFile = file.getParentFile();
101
+        if (!parentFile.exists()) {
102
+            parentFile.mkdirs();
103
+        }
104
+        try (FileOutputStream out = new FileOutputStream(path + "/" + fileId + "." + fileType)) {
105
+            out.write(bytes);
106
+            out.flush();
107
+        }
108
+        return fileId;
109
+    }
73
 }
110
 }

+ 22
- 10
src/main/java/com/oo/onlyoffice/api/impl/OnlyServiceAPIImpl.java Näytä tiedosto

81
             return documentEdit(map, collaborativeEditing, clientType);
81
             return documentEdit(map, collaborativeEditing, clientType);
82
         }
82
         }
83
         if (VIEW.equals(mode)) {
83
         if (VIEW.equals(mode)) {
84
-            return documentView(map, clientType);
84
+            return documentView(map, collaborativeEditing, clientType);
85
         }
85
         }
86
+//        if (VIEW.equals(mode)) {
87
+//            return documentView(map, clientType);
88
+//        }
86
         return null;
89
         return null;
87
     }
90
     }
88
 
91
 
89
     private Map documentEdit(Map<String, Object> map, boolean collaborativeEditing, String clientType) {
92
     private Map documentEdit(Map<String, Object> map, boolean collaborativeEditing, String clientType) {
90
-        FileConfig fileConfigDTO = openEditConfig(map, "edit", collaborativeEditing,clientType);
93
+        FileConfig fileConfigDTO = openEditConfig(map, "edit", collaborativeEditing, clientType);
91
         String json = JSON.toJSONString(fileConfigDTO);
94
         String json = JSON.toJSONString(fileConfigDTO);
92
         Map<String, Object> config = JSON.parseObject(json, Map.class);
95
         Map<String, Object> config = JSON.parseObject(json, Map.class);
93
         config.put("type", clientType);
96
         config.put("type", clientType);
94
         return config;
97
         return config;
95
     }
98
     }
96
 
99
 
100
+    private Map documentView(Map<String, Object> map, boolean collaborativeEditing, String clientType) {
101
+        FileConfig fileConfigDTO = openEditConfig(map, "view", collaborativeEditing, clientType);
102
+        String json = JSON.toJSONString(fileConfigDTO);
103
+        Map<String, Object> config = JSON.parseObject(json, Map.class);
104
+        config.put("type", clientType);
105
+        return config;
106
+    }
97
 
107
 
98
-    private Map documentView(Map<String, Object> map,String clientType) {
99
-        FileConfig fileConfigDTO = openEditConfig(map, "view", false,clientType);
108
+    private Map documentView(Map<String, Object> map, String clientType) {
109
+        FileConfig fileConfigDTO = openEditConfig(map, "view", false, clientType);
100
         String json = JSON.toJSONString(fileConfigDTO);
110
         String json = JSON.toJSONString(fileConfigDTO);
101
         Map<String, Object> config = JSON.parseObject(json, Map.class);
111
         Map<String, Object> config = JSON.parseObject(json, Map.class);
102
         config.put("type", clientType);
112
         config.put("type", clientType);
103
         return config;
113
         return config;
104
     }
114
     }
105
 
115
 
106
-    private FileConfig openEditConfig(Map<String, Object> map, String mode, boolean collaborativeEditing,String clientType) {
116
+    private FileConfig openEditConfig(Map<String, Object> map, String mode, boolean collaborativeEditing, String clientType) {
107
         try {
117
         try {
108
             map.put("mode", mode);
118
             map.put("mode", mode);
109
             log.info("开始生成文件信息");
119
             log.info("开始生成文件信息");
111
             FileMetadata tempFileInfo = fileHandler.handlerFile(map, collaborativeEditing);
121
             FileMetadata tempFileInfo = fileHandler.handlerFile(map, collaborativeEditing);
112
             //生成配置文件 TODO: 控制文件权限
122
             //生成配置文件 TODO: 控制文件权限
113
             log.info("开始生成编辑器配置信息");
123
             log.info("开始生成编辑器配置信息");
114
-            FileConfig fileConfigDTO = onlyOfficeConfigFactory.buildInitConfig(tempFileInfo.getUrl(), mode, tempFileInfo.getKey(), tempFileInfo.getOldName(),clientType);
124
+            FileConfig fileConfigDTO = onlyOfficeConfigFactory.buildInitConfig(tempFileInfo.getUrl(), mode, tempFileInfo.getKey(), tempFileInfo.getOldName(), clientType);
115
             log.info("生成编辑器配置信息结束");
125
             log.info("生成编辑器配置信息结束");
116
             // TODO: 添加更多详细的自定义信息
126
             // TODO: 添加更多详细的自定义信息
117
             return fileConfigDTO;
127
             return fileConfigDTO;
160
     @Override
170
     @Override
161
     public OnFile handlerStatus(JSONObject jsonObject) throws Exception {
171
     public OnFile handlerStatus(JSONObject jsonObject) throws Exception {
162
         OnFile file = new OnFile();
172
         OnFile file = new OnFile();
163
-        String fileId = null;
173
+        String fileId = jsonObject.getString("fileId");
164
         log.info("开始下载编辑器文件");
174
         log.info("开始下载编辑器文件");
165
         int status = jsonObject.getIntValue("status");
175
         int status = jsonObject.getIntValue("status");
166
         log.info("status[{}]:{}", status, jsonObject);
176
         log.info("status[{}]:{}", status, jsonObject);
192
                 if (caseId != null) {
202
                 if (caseId != null) {
193
                     fileInfoMap.put("caseId", caseId);
203
                     fileInfoMap.put("caseId", caseId);
194
                 }
204
                 }
195
-                saveFileProcessor.saveBeforeInitialization(tempFile.get().getFileInfo(), fileByte, fileExtension);
205
+                //保存文件前进行自定义处理(该方法暂时没有实现业务逻辑)
206
+                //saveFileProcessor.saveBeforeInitialization(tempFile.get().getFileInfo(), fileByte, fileExtension);
196
 
207
 
197
                 // 保存文件
208
                 // 保存文件
198
-                Map<String, Object> map = saveFileProcessor.save(tempFile.get().getFileInfo(), fileByte, changes, key);
209
+                Map<String, Object> map = saveFileProcessor.save(tempFile.get().getFileInfo(), fileByte, changes, fileId);
199
                 log.info("文件信息1:" + JSON.toJSONString(tempFile.get().getFileInfo()));
210
                 log.info("文件信息1:" + JSON.toJSONString(tempFile.get().getFileInfo()));
200
                 log.info("文件信息2:" + JSON.toJSONString(map));
211
                 log.info("文件信息2:" + JSON.toJSONString(map));
201
                 saveFileProcessor.saveAfterInitialization(tempFile.get().getFileInfo(), fileByte, fileExtension);
212
                 saveFileProcessor.saveAfterInitialization(tempFile.get().getFileInfo(), fileByte, fileExtension);
300
                 log.info("文件变动信息文件url:" + changesurl);
311
                 log.info("文件变动信息文件url:" + changesurl);
301
                 // 下载修改后文件
312
                 // 下载修改后文件
302
                 byte[] fileByte = FileUtil.getFileByte(url);
313
                 byte[] fileByte = FileUtil.getFileByte(url);
303
-                saveFileProcessor.save(tempFile.getFileInfo(), fileByte, null, jsonObject.getString("key"));
314
+                saveFileProcessor.save(tempFile.getFileInfo(), fileByte, null, jsonObject.getString("fileId"));
315
+                log.info("zouzhele==================");
304
             }
316
             }
305
             removeTempFile(jsonObject);
317
             removeTempFile(jsonObject);
306
             String id = (String) cache.get("getID_" + jsonObject.getString("key"));
318
             String id = (String) cache.get("getID_" + jsonObject.getString("key"));

+ 11
- 6
src/main/java/com/oo/onlyoffice/core/FileConfigFactory.java Näytä tiedosto

1
 package com.oo.onlyoffice.core;
1
 package com.oo.onlyoffice.core;
2
 
2
 
3
 import cn.hutool.core.date.DateUtil;
3
 import cn.hutool.core.date.DateUtil;
4
+import com.alibaba.fastjson2.JSONObject;
4
 import com.oo.onlyoffice.config.OnlyProperties;
5
 import com.oo.onlyoffice.config.OnlyProperties;
5
 import com.oo.onlyoffice.dto.DocumentConfig;
6
 import com.oo.onlyoffice.dto.DocumentConfig;
6
 import com.oo.onlyoffice.dto.EditorConfig;
7
 import com.oo.onlyoffice.dto.EditorConfig;
43
      * @return 配置信息
44
      * @return 配置信息
44
      */
45
      */
45
     @Override
46
     @Override
46
-    public FileConfig buildInitConfig(String fileUrl, String mode, String key, String fileName,String clientType) {
47
+    public FileConfig buildInitConfig(String fileUrl, String mode, String key, String fileName, String clientType) {
47
 
48
 
48
         Map<String, Object> map = new HashMap<>();
49
         Map<String, Object> map = new HashMap<>();
49
 
50
 
74
         String callBackUrl = onlyProperties.getLocalhostAddress() + onlyProperties.getCallBackUrl();
75
         String callBackUrl = onlyProperties.getLocalhostAddress() + onlyProperties.getCallBackUrl();
75
 
76
 
76
         EditorConfig editorConfig = new EditorConfig(callBackUrl, mode);
77
         EditorConfig editorConfig = new EditorConfig(callBackUrl, mode);
77
-        editorConfig.setFileCustomization(getFileCustomization(mode,clientType));
78
+        editorConfig.setFileCustomization(getFileCustomization(mode, clientType));
78
         editorConfig.setFileUser(user);
79
         editorConfig.setFileUser(user);
79
         editorConfig.setPlugins(getPlugins());
80
         editorConfig.setPlugins(getPlugins());
80
-
81
-
81
+        //共同编辑"coEditing"配置:
82
+        //        "coEditing": {           "mode": "fast","change": true}
83
+        JSONObject coEditing = new JSONObject();
84
+        coEditing.put("mode", "fast");
85
+        coEditing.put("change", "true");
86
+        editorConfig.setCoEditing(coEditing);
82
         fileConfigDTO.setEditorConfig(editorConfig);
87
         fileConfigDTO.setEditorConfig(editorConfig);
83
         map.put("editorConfig", editorConfig);
88
         map.put("editorConfig", editorConfig);
84
 
89
 
112
         return LoadConfigUtil.getCustomization();
117
         return LoadConfigUtil.getCustomization();
113
     }
118
     }
114
 
119
 
115
-    private FileCustomization getFileCustomization(String mode,String clientType) {
120
+    private FileCustomization getFileCustomization(String mode, String clientType) {
116
         FileCustomization customization = LoadConfigUtil.getCustomization();
121
         FileCustomization customization = LoadConfigUtil.getCustomization();
117
         if (mode != null && !(mode.trim()).equals("") && mode.equals("edit")) {
122
         if (mode != null && !(mode.trim()).equals("") && mode.equals("edit")) {
118
             customization.setAutosave(true);
123
             customization.setAutosave(true);
119
         }
124
         }
120
         customization.setMobileForceView(false);
125
         customization.setMobileForceView(false);
121
-        if(clientType!=null&&clientType!=""&&"mobile".equals(clientType)){
126
+        if (clientType != null && clientType != "" && "mobile".equals(clientType)) {
122
             customization.setMobileForceView(true);
127
             customization.setMobileForceView(true);
123
         }
128
         }
124
         return customization;
129
         return customization;

+ 4
- 3
src/main/java/com/oo/onlyoffice/core/SaveFileProcessor.java Näytä tiedosto

16
      void saveBeforeInitialization(Map<String, Object> map,byte[] bytes,String fileExtension) throws Exception;
16
      void saveBeforeInitialization(Map<String, Object> map,byte[] bytes,String fileExtension) throws Exception;
17
 
17
 
18
     /**
18
     /**
19
-     *
19
+     * 存储onlyoffice文件信息
20
      * @param map     文件元信息
20
      * @param map     文件元信息
21
      * @param file    文件
21
      * @param file    文件
22
      * @param changes 文件变动信息
22
      * @param changes 文件变动信息
23
-     * @return 返回新的文件信息
23
+     * @param fileId 文件id
24
+     * @return
24
      */
25
      */
25
-    Map<String, Object> save(Map<String, Object> map,byte[] file, byte[] changes,String key);
26
+    Map<String, Object> save(Map<String, Object> map,byte[] file, byte[] changes,String fileId);
26
 
27
 
27
     /**
28
     /**
28
      * 保存文件后进行自定义处理
29
      * 保存文件后进行自定义处理

+ 17
- 2
src/main/java/com/oo/onlyoffice/core/handler/FileHandlerImpl.java Näytä tiedosto

77
                     cache.set(user.getId() + "_" + id, key);
77
                     cache.set(user.getId() + "_" + id, key);
78
                     cache.set("getID_" + key, id);
78
                     cache.set("getID_" + key, id);
79
                 }
79
                 }
80
-            } else {//查看模式
81
-                key = id;
80
+            } else {
81
+                //查看模式
82
+                if (collaborativeEditing) {
83
+                    if (cache.get("collaborativeEditing_" + id) != null) {
84
+                        key = (String) cache.get("collaborativeEditing_" + id);
85
+                    } else {
86
+                        key = IdUtil.simpleUUID();
87
+                        cache.set("collaborativeEditing_" + id, key);
88
+                        cache.set("getID_" + key, id);
89
+                    }
90
+                } else {
91
+                    key = IdUtil.simpleUUID();
92
+                    FileUser user = SecurityUtils.getUserSession();
93
+                    cache.set(user.getId() + "_" + id, key);
94
+                    cache.set("getID_" + key, id);
95
+                }
96
+              //  key = id;
82
             }
97
             }
83
 
98
 
84
 
99
 

+ 21
- 5
src/main/resources/application.yml Näytä tiedosto

22
   datasource:
22
   datasource:
23
     type: com.alibaba.druid.pool.DruidDataSource
23
     type: com.alibaba.druid.pool.DruidDataSource
24
     driver-class-name: com.mysql.cj.jdbc.Driver
24
     driver-class-name: com.mysql.cj.jdbc.Driver
25
-    url: jdbc:mysql://121.40.189.20:3306/onlyoffice?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai&useSSL=false
25
+    url: jdbc:mysql://121.40.189.20:3306/onlyoffice_test?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai&useSSL=false
26
     username: root
26
     username: root
27
     password: YMzc157#
27
     password: YMzc157#
28
   redis:
28
   redis:
29
     host: 121.40.189.20
29
     host: 121.40.189.20
30
     port: 6389
30
     port: 6389
31
-    database: 0
31
+    database: 1
32
 
32
 
33
 mybatis-plus:
33
 mybatis-plus:
34
   #  global-config:
34
   #  global-config:
45
   config:
45
   config:
46
     activate:
46
     activate:
47
       on-profile: dev
47
       on-profile: dev
48
-filepath: C:/onlyoffice/data/files
49
-serverhost: http://172.16.0.254
48
+  datasource:
49
+    type: com.alibaba.druid.pool.DruidDataSource
50
+    driver-class-name: com.mysql.cj.jdbc.Driver
51
+    url: jdbc:mysql://121.40.189.20:3306/onlyoffice_test?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai&useSSL=false
52
+    username: root
53
+    password: YMzc157#
54
+filepath: /home/ruoyi/uploadPath/onlyoffice/data/files
55
+serverhost: http://121.40.189.20
50
 ---
56
 ---
51
 #生产环境属性配置
57
 #生产环境属性配置
52
 spring:
58
 spring:
53
   config:
59
   config:
54
     activate:
60
     activate:
55
       on-profile: prod
61
       on-profile: prod
56
-filepath: /onlyoffice/data/files
62
+  redis:
63
+    host: 121.40.189.20
64
+    port: 6389
65
+    database: 0
66
+  datasource:
67
+    type: com.alibaba.druid.pool.DruidDataSource
68
+    driver-class-name: com.mysql.cj.jdbc.Driver
69
+    url: jdbc:mysql://121.40.189.20:3306/onlyoffice?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai&useSSL=false
70
+    username: root
71
+    password: YMzc157#
72
+filepath: /home/ruoyi/uploadPath/onlyoffice/data/files
57
 serverhost: http://121.40.189.20
73
 serverhost: http://121.40.189.20