优化回调保存接口(若传递文件id则每次保存只更新文件) #3

Merged
bgy merged 3 commits from bgy into dev 2024-05-11 08:41:49 +00:00
3 changed files with 45 additions and 15 deletions
Showing only changes of commit bbfb6ea88d - Show all commits
@@ -81,8 +81,11 @@ public class OnlyServiceAPIImpl implements OnlyServiceAPI {
return documentEdit(map, collaborativeEditing, clientType);
}
if (VIEW.equals(mode)) {
return documentView(map, clientType);
return documentView(map, collaborativeEditing, clientType);
}
// if (VIEW.equals(mode)) {
// return documentView(map, clientType);
// }
return null;
}
@@ -94,6 +97,13 @@ public class OnlyServiceAPIImpl implements OnlyServiceAPI {
return config;
}
private Map documentView(Map<String, Object> map, boolean collaborativeEditing, String clientType) {
FileConfig fileConfigDTO = openEditConfig(map, "view", collaborativeEditing, clientType);
String json = JSON.toJSONString(fileConfigDTO);
Map<String, Object> config = JSON.parseObject(json, Map.class);
config.put("type", clientType);
return config;
}
private Map documentView(Map<String, Object> map, String clientType) {
FileConfig fileConfigDTO = openEditConfig(map, "view", false, clientType);
@@ -1,6 +1,7 @@
package com.oo.onlyoffice.core;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson2.JSONObject;
import com.oo.onlyoffice.config.OnlyProperties;
import com.oo.onlyoffice.dto.DocumentConfig;
import com.oo.onlyoffice.dto.EditorConfig;
@@ -77,8 +78,12 @@ public class FileConfigFactory implements OnlyOfficeConfigFactory {
editorConfig.setFileCustomization(getFileCustomization(mode, clientType));
editorConfig.setFileUser(user);
editorConfig.setPlugins(getPlugins());
//共同编辑"coEditing"配置:
// "coEditing": { "mode": "fast","change": true}
JSONObject coEditing = new JSONObject();
coEditing.put("mode", "fast");
coEditing.put("change", "true");
editorConfig.setCoEditing(coEditing);
fileConfigDTO.setEditorConfig(editorConfig);
map.put("editorConfig", editorConfig);
@@ -77,8 +77,23 @@ public class FileHandlerImpl implements FileHandler {
cache.set(user.getId() + "_" + id, key);
cache.set("getID_" + key, id);
}
} else {//查看模式
key = id;
} else {
//查看模式
if (collaborativeEditing) {
if (cache.get("collaborativeEditing_" + id) != null) {
key = (String) cache.get("collaborativeEditing_" + id);
} else {
key = IdUtil.simpleUUID();
cache.set("collaborativeEditing_" + id, key);
cache.set("getID_" + key, id);
}
} else {
key = IdUtil.simpleUUID();
FileUser user = SecurityUtils.getUserSession();
cache.set(user.getId() + "_" + id, key);
cache.set("getID_" + key, id);
}
// key = id;
}