优化回调保存接口(若传递文件id则每次保存只更新文件) #3
@@ -236,9 +236,9 @@ public class OnlyOfficeController {
|
|||||||
* 6 - 正在编辑文档,但保存当前文档状态
|
* 6 - 正在编辑文档,但保存当前文档状态
|
||||||
* 7 - 强制保存文档时发生错误
|
* 7 - 强制保存文档时发生错误
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/onlyOffice/save")
|
@RequestMapping("/onlyOffice/save/{fileId}")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public void saveFile(HttpServletRequest request, HttpServletResponse response) {
|
public void saveFile(HttpServletRequest request, HttpServletResponse response,@PathVariable(required = false) String fileId) {
|
||||||
PrintWriter writer = null;
|
PrintWriter writer = null;
|
||||||
try {
|
try {
|
||||||
writer = response.getWriter();
|
writer = response.getWriter();
|
||||||
@@ -246,6 +246,11 @@ public class OnlyOfficeController {
|
|||||||
Scanner scanner = new Scanner(request.getInputStream()).useDelimiter("\\A");
|
Scanner scanner = new Scanner(request.getInputStream()).useDelimiter("\\A");
|
||||||
String body = scanner.hasNext() ? scanner.next() : "";
|
String body = scanner.hasNext() ? scanner.next() : "";
|
||||||
JSONObject jsonObject = JSONObject.parseObject(body);
|
JSONObject jsonObject = JSONObject.parseObject(body);
|
||||||
|
if(fileId!=null){
|
||||||
|
jsonObject.put("fileId",fileId);
|
||||||
|
}else{
|
||||||
|
jsonObject.put("fileId","");
|
||||||
|
}
|
||||||
log.info("{}", jsonObject);
|
log.info("{}", jsonObject);
|
||||||
WebsocketResult result = fileService.documentSave(jsonObject);
|
WebsocketResult result = fileService.documentSave(jsonObject);
|
||||||
/*
|
/*
|
||||||
@@ -258,9 +263,10 @@ public class OnlyOfficeController {
|
|||||||
userId = userSession.getId();
|
userId = userSession.getId();
|
||||||
}
|
}
|
||||||
WebSocketServer.sendInfo(JSON.toJSONString(result.getOnFile()), userId);
|
WebSocketServer.sendInfo(JSON.toJSONString(result.getOnFile()), userId);
|
||||||
if (Objects.nonNull(writer)) {
|
// if (Objects.nonNull(writer)) {
|
||||||
writer.write("{\"error\":0}");
|
// writer.write("{\"error\":0}");
|
||||||
}
|
// }
|
||||||
|
writer.write("{\"error\":0}");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
log.info("报错信息" + e.getMessage());
|
log.info("报错信息" + e.getMessage());
|
||||||
|
|||||||
@@ -36,11 +36,23 @@ public class DemoService implements SaveFileProcessor {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存储onlyoffice文件信息
|
||||||
|
* @param map 文件元信息
|
||||||
|
* @param file 文件
|
||||||
|
* @param changes 文件变动信息
|
||||||
|
* @param fileId 文件id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> save(Map<String, Object> map, byte[] file, byte[] changes, String key) {
|
public Map<String, Object> save(Map<String, Object> map, byte[] file, byte[] changes, String fileId) {
|
||||||
String fileId = "";
|
|
||||||
try {
|
try {
|
||||||
|
if(fileId!=null&&fileId!=""){
|
||||||
|
onFileService.updateFileByFileId(file, map.get("fileType").toString(),fileId);
|
||||||
|
}else{
|
||||||
|
fileId = "";
|
||||||
fileId = onFileService.saveFile(file, map.get("fileType").toString());
|
fileId = onFileService.saveFile(file, map.get("fileType").toString());
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ public class FileService {
|
|||||||
public WebsocketResult documentSave(JSONObject jsonObject) {
|
public WebsocketResult documentSave(JSONObject jsonObject) {
|
||||||
WebsocketResult result = new WebsocketResult();
|
WebsocketResult result = new WebsocketResult();
|
||||||
String key = "";
|
String key = "";
|
||||||
|
String fileId = jsonObject.getString("fileId");
|
||||||
try {
|
try {
|
||||||
int status = jsonObject.getIntValue("status");
|
int status = jsonObject.getIntValue("status");
|
||||||
log.info("status[{}]", status);
|
log.info("status[{}]", status);
|
||||||
@@ -69,7 +70,13 @@ public class FileService {
|
|||||||
key = jsonObject.getString("key");
|
key = jsonObject.getString("key");
|
||||||
log.info("key:" + JSON.toJSONString(key));
|
log.info("key:" + JSON.toJSONString(key));
|
||||||
//文件id
|
//文件id
|
||||||
String fileId = onlyServiceAPI.getFileId(key);
|
Boolean isexistid = false;
|
||||||
|
if (fileId != null && !"".equals(fileId)) {
|
||||||
|
isexistid = true;
|
||||||
|
}
|
||||||
|
if (!isexistid) {
|
||||||
|
fileId = onlyServiceAPI.getFileId(key);
|
||||||
|
}
|
||||||
log.info("fileId:" + JSON.toJSONString(fileId));
|
log.info("fileId:" + JSON.toJSONString(fileId));
|
||||||
if (fileId != null && !"".equals(fileId)) {
|
if (fileId != null && !"".equals(fileId)) {
|
||||||
//查询之前FileId对应的文件信息
|
//查询之前FileId对应的文件信息
|
||||||
@@ -93,7 +100,11 @@ public class FileService {
|
|||||||
//处理文件的保存
|
//处理文件的保存
|
||||||
OnFile file = onlyServiceAPI.handlerStatus(jsonObject);
|
OnFile file = onlyServiceAPI.handlerStatus(jsonObject);
|
||||||
//查询相同案件最新版本的文件信息
|
//查询相同案件最新版本的文件信息
|
||||||
file = getNewFileInofoByCaseId(file.getCaseId());
|
if (fileId != null && !"".equals(fileId)) {
|
||||||
|
file = getNewFileInofoByFileId(fileId);
|
||||||
|
} else {
|
||||||
|
file = getNewFileInofoByCaseId(file.getCaseId());
|
||||||
|
}
|
||||||
result = WebsocketResult.builder().onFile(file).userId(SecurityUtils.getUserSession().getId()).build();
|
result = WebsocketResult.builder().onFile(file).userId(SecurityUtils.getUserSession().getId()).build();
|
||||||
log.info("处理文件的保存:" + JSON.toJSONString(jsonObject));
|
log.info("处理文件的保存:" + JSON.toJSONString(jsonObject));
|
||||||
log.info("保存文件结束");
|
log.info("保存文件结束");
|
||||||
@@ -101,10 +112,13 @@ public class FileService {
|
|||||||
return result;
|
return result;
|
||||||
} else if (0 == status || 2 == status || 4 == status) {
|
} else if (0 == status || 2 == status || 4 == status) {
|
||||||
onlyServiceAPI.close(jsonObject);
|
onlyServiceAPI.close(jsonObject);
|
||||||
|
log.info("文件关闭====",status);
|
||||||
} else if (3 == status || 7 == status) {
|
} else if (3 == status || 7 == status) {
|
||||||
//保存文档错误
|
//保存文档错误
|
||||||
onlyServiceAPI.close(jsonObject);
|
onlyServiceAPI.close(jsonObject);
|
||||||
|
log.info("保存文档错误====",status);
|
||||||
} else if (1 == status) {
|
} else if (1 == status) {
|
||||||
|
log.info("文件正在编辑====",status);
|
||||||
//文件服务的回调 获取key判断当前文档有多少人在这使用
|
//文件服务的回调 获取key判断当前文档有多少人在这使用
|
||||||
List<Map> actions = JSONObject.parseArray(jsonObject.getString("actions"), Map.class);
|
List<Map> actions = JSONObject.parseArray(jsonObject.getString("actions"), Map.class);
|
||||||
if ((Integer) actions.get(0).get("type") == 1) {
|
if ((Integer) actions.get(0).get("type") == 1) {
|
||||||
@@ -145,4 +159,17 @@ public class FileService {
|
|||||||
log.info("caseId:" + caseId + ":fileinfo:" + JSON.toJSONString(file));
|
log.info("caseId:" + caseId + ":fileinfo:" + JSON.toJSONString(file));
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据文件的fileid查询文件信息
|
||||||
|
*/
|
||||||
|
private OnFile getNewFileInofoByFileId(String fileId) {
|
||||||
|
OnFile file = onFileMapper.selectById(fileId);
|
||||||
|
if (file != null) {
|
||||||
|
log.info("caseId:" + file.getCaseId() + ":fileinfo:" + JSON.toJSONString(file));
|
||||||
|
} else {
|
||||||
|
log.info("根据文件id未查询到文件信息");
|
||||||
|
}
|
||||||
|
return file;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
import com.oo.demo.entity.OnFile;
|
import com.oo.demo.entity.OnFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
|
|
||||||
public interface OnFileService extends IService<OnFile> {
|
public interface OnFileService extends IService<OnFile> {
|
||||||
/**
|
/**
|
||||||
* 保存onlyoffice文件
|
* 保存onlyoffice文件
|
||||||
|
*
|
||||||
* @param bytes
|
* @param bytes
|
||||||
* @param fileType
|
* @param fileType
|
||||||
* @return
|
* @return
|
||||||
@@ -17,14 +17,27 @@ public interface OnFileService extends IService<OnFile> {
|
|||||||
*/
|
*/
|
||||||
String saveFile(byte[] bytes, String fileType) throws Exception;
|
String saveFile(byte[] bytes, String fileType) throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过文件id更新onlyoffice文件
|
||||||
|
*
|
||||||
|
* @param bytes
|
||||||
|
* @param fileType
|
||||||
|
* @param fileId
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
String updateFileByFileId(byte[] bytes, String fileType, String fileId) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除onlyoffice文件
|
* 删除onlyoffice文件
|
||||||
|
*
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
void removeFile(String id);
|
void removeFile(String id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 下载onlyoffice文件
|
* 下载onlyoffice文件
|
||||||
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @param isBrowser
|
* @param isBrowser
|
||||||
* @param response
|
* @param response
|
||||||
@@ -33,6 +46,7 @@ public interface OnFileService extends IService<OnFile> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据文件id查找文件信息
|
* 根据文件id查找文件信息
|
||||||
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -56,6 +56,14 @@ public class OnFileServiceImpl extends ServiceImpl<OnFileMapper, OnFile> impleme
|
|||||||
removeById(id);
|
removeById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增文件信息到数据库
|
||||||
|
*
|
||||||
|
* @param bytes
|
||||||
|
* @param fileType
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
public String saveFile(byte[] bytes, String fileType) throws Exception {
|
public String saveFile(byte[] bytes, String fileType) throws Exception {
|
||||||
|
|
||||||
String fileId = IdUtil.simpleUUID();
|
String fileId = IdUtil.simpleUUID();
|
||||||
@@ -70,4 +78,33 @@ public class OnFileServiceImpl extends ServiceImpl<OnFileMapper, OnFile> impleme
|
|||||||
}
|
}
|
||||||
return fileId;
|
return fileId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新文件信息到数据库
|
||||||
|
*
|
||||||
|
* @param bytes
|
||||||
|
* @param fileType
|
||||||
|
* @param fileId
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public String updateFileByFileId(byte[] bytes, String fileType, String fileId) throws Exception {
|
||||||
|
Boolean ishaveid = false;
|
||||||
|
if (fileId != null && fileId != "") {
|
||||||
|
ishaveid = true;
|
||||||
|
}
|
||||||
|
if (!ishaveid) {
|
||||||
|
fileId = IdUtil.simpleUUID();
|
||||||
|
}
|
||||||
|
File file = new File(path + "/" + fileId + "." + fileType);
|
||||||
|
File parentFile = file.getParentFile();
|
||||||
|
if (!parentFile.exists()) {
|
||||||
|
parentFile.mkdirs();
|
||||||
|
}
|
||||||
|
try (FileOutputStream out = new FileOutputStream(path + "/" + fileId + "." + fileType)) {
|
||||||
|
out.write(bytes);
|
||||||
|
out.flush();
|
||||||
|
}
|
||||||
|
return fileId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,29 +81,39 @@ public class OnlyServiceAPIImpl implements OnlyServiceAPI {
|
|||||||
return documentEdit(map, collaborativeEditing, clientType);
|
return documentEdit(map, collaborativeEditing, clientType);
|
||||||
}
|
}
|
||||||
if (VIEW.equals(mode)) {
|
if (VIEW.equals(mode)) {
|
||||||
return documentView(map, clientType);
|
return documentView(map, collaborativeEditing, clientType);
|
||||||
}
|
}
|
||||||
|
// if (VIEW.equals(mode)) {
|
||||||
|
// return documentView(map, clientType);
|
||||||
|
// }
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map documentEdit(Map<String, Object> map, boolean collaborativeEditing, String clientType) {
|
private Map documentEdit(Map<String, Object> map, boolean collaborativeEditing, String clientType) {
|
||||||
FileConfig fileConfigDTO = openEditConfig(map, "edit", collaborativeEditing,clientType);
|
FileConfig fileConfigDTO = openEditConfig(map, "edit", collaborativeEditing, clientType);
|
||||||
String json = JSON.toJSONString(fileConfigDTO);
|
String json = JSON.toJSONString(fileConfigDTO);
|
||||||
Map<String, Object> config = JSON.parseObject(json, Map.class);
|
Map<String, Object> config = JSON.parseObject(json, Map.class);
|
||||||
config.put("type", clientType);
|
config.put("type", clientType);
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map documentView(Map<String, Object> map, boolean collaborativeEditing, String clientType) {
|
||||||
private Map documentView(Map<String, Object> map,String clientType) {
|
FileConfig fileConfigDTO = openEditConfig(map, "view", collaborativeEditing, clientType);
|
||||||
FileConfig fileConfigDTO = openEditConfig(map, "view", false,clientType);
|
|
||||||
String json = JSON.toJSONString(fileConfigDTO);
|
String json = JSON.toJSONString(fileConfigDTO);
|
||||||
Map<String, Object> config = JSON.parseObject(json, Map.class);
|
Map<String, Object> config = JSON.parseObject(json, Map.class);
|
||||||
config.put("type", clientType);
|
config.put("type", clientType);
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
private FileConfig openEditConfig(Map<String, Object> map, String mode, boolean collaborativeEditing,String clientType) {
|
private Map documentView(Map<String, Object> map, String clientType) {
|
||||||
|
FileConfig fileConfigDTO = openEditConfig(map, "view", false, clientType);
|
||||||
|
String json = JSON.toJSONString(fileConfigDTO);
|
||||||
|
Map<String, Object> config = JSON.parseObject(json, Map.class);
|
||||||
|
config.put("type", clientType);
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
private FileConfig openEditConfig(Map<String, Object> map, String mode, boolean collaborativeEditing, String clientType) {
|
||||||
try {
|
try {
|
||||||
map.put("mode", mode);
|
map.put("mode", mode);
|
||||||
log.info("开始生成文件信息");
|
log.info("开始生成文件信息");
|
||||||
@@ -111,7 +121,7 @@ public class OnlyServiceAPIImpl implements OnlyServiceAPI {
|
|||||||
FileMetadata tempFileInfo = fileHandler.handlerFile(map, collaborativeEditing);
|
FileMetadata tempFileInfo = fileHandler.handlerFile(map, collaborativeEditing);
|
||||||
//生成配置文件 TODO: 控制文件权限
|
//生成配置文件 TODO: 控制文件权限
|
||||||
log.info("开始生成编辑器配置信息");
|
log.info("开始生成编辑器配置信息");
|
||||||
FileConfig fileConfigDTO = onlyOfficeConfigFactory.buildInitConfig(tempFileInfo.getUrl(), mode, tempFileInfo.getKey(), tempFileInfo.getOldName(),clientType);
|
FileConfig fileConfigDTO = onlyOfficeConfigFactory.buildInitConfig(tempFileInfo.getUrl(), mode, tempFileInfo.getKey(), tempFileInfo.getOldName(), clientType);
|
||||||
log.info("生成编辑器配置信息结束");
|
log.info("生成编辑器配置信息结束");
|
||||||
// TODO: 添加更多详细的自定义信息
|
// TODO: 添加更多详细的自定义信息
|
||||||
return fileConfigDTO;
|
return fileConfigDTO;
|
||||||
@@ -160,7 +170,7 @@ public class OnlyServiceAPIImpl implements OnlyServiceAPI {
|
|||||||
@Override
|
@Override
|
||||||
public OnFile handlerStatus(JSONObject jsonObject) throws Exception {
|
public OnFile handlerStatus(JSONObject jsonObject) throws Exception {
|
||||||
OnFile file = new OnFile();
|
OnFile file = new OnFile();
|
||||||
String fileId = null;
|
String fileId = jsonObject.getString("fileId");
|
||||||
log.info("开始下载编辑器文件");
|
log.info("开始下载编辑器文件");
|
||||||
int status = jsonObject.getIntValue("status");
|
int status = jsonObject.getIntValue("status");
|
||||||
log.info("status[{}]:{}", status, jsonObject);
|
log.info("status[{}]:{}", status, jsonObject);
|
||||||
@@ -192,10 +202,11 @@ public class OnlyServiceAPIImpl implements OnlyServiceAPI {
|
|||||||
if (caseId != null) {
|
if (caseId != null) {
|
||||||
fileInfoMap.put("caseId", caseId);
|
fileInfoMap.put("caseId", caseId);
|
||||||
}
|
}
|
||||||
saveFileProcessor.saveBeforeInitialization(tempFile.get().getFileInfo(), fileByte, fileExtension);
|
//保存文件前进行自定义处理(该方法暂时没有实现业务逻辑)
|
||||||
|
//saveFileProcessor.saveBeforeInitialization(tempFile.get().getFileInfo(), fileByte, fileExtension);
|
||||||
|
|
||||||
// 保存文件
|
// 保存文件
|
||||||
Map<String, Object> map = saveFileProcessor.save(tempFile.get().getFileInfo(), fileByte, changes, key);
|
Map<String, Object> map = saveFileProcessor.save(tempFile.get().getFileInfo(), fileByte, changes, fileId);
|
||||||
log.info("文件信息1:" + JSON.toJSONString(tempFile.get().getFileInfo()));
|
log.info("文件信息1:" + JSON.toJSONString(tempFile.get().getFileInfo()));
|
||||||
log.info("文件信息2:" + JSON.toJSONString(map));
|
log.info("文件信息2:" + JSON.toJSONString(map));
|
||||||
saveFileProcessor.saveAfterInitialization(tempFile.get().getFileInfo(), fileByte, fileExtension);
|
saveFileProcessor.saveAfterInitialization(tempFile.get().getFileInfo(), fileByte, fileExtension);
|
||||||
@@ -300,7 +311,8 @@ public class OnlyServiceAPIImpl implements OnlyServiceAPI {
|
|||||||
log.info("文件变动信息文件url:" + changesurl);
|
log.info("文件变动信息文件url:" + changesurl);
|
||||||
// 下载修改后文件
|
// 下载修改后文件
|
||||||
byte[] fileByte = FileUtil.getFileByte(url);
|
byte[] fileByte = FileUtil.getFileByte(url);
|
||||||
saveFileProcessor.save(tempFile.getFileInfo(), fileByte, null, jsonObject.getString("key"));
|
saveFileProcessor.save(tempFile.getFileInfo(), fileByte, null, jsonObject.getString("fileId"));
|
||||||
|
log.info("zouzhele==================");
|
||||||
}
|
}
|
||||||
removeTempFile(jsonObject);
|
removeTempFile(jsonObject);
|
||||||
String id = (String) cache.get("getID_" + jsonObject.getString("key"));
|
String id = (String) cache.get("getID_" + jsonObject.getString("key"));
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.oo.onlyoffice.core;
|
package com.oo.onlyoffice.core;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.oo.onlyoffice.config.OnlyProperties;
|
import com.oo.onlyoffice.config.OnlyProperties;
|
||||||
import com.oo.onlyoffice.dto.DocumentConfig;
|
import com.oo.onlyoffice.dto.DocumentConfig;
|
||||||
import com.oo.onlyoffice.dto.EditorConfig;
|
import com.oo.onlyoffice.dto.EditorConfig;
|
||||||
@@ -43,7 +44,7 @@ public class FileConfigFactory implements OnlyOfficeConfigFactory {
|
|||||||
* @return 配置信息
|
* @return 配置信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public FileConfig buildInitConfig(String fileUrl, String mode, String key, String fileName,String clientType) {
|
public FileConfig buildInitConfig(String fileUrl, String mode, String key, String fileName, String clientType) {
|
||||||
|
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
|
||||||
@@ -74,11 +75,15 @@ public class FileConfigFactory implements OnlyOfficeConfigFactory {
|
|||||||
String callBackUrl = onlyProperties.getLocalhostAddress() + onlyProperties.getCallBackUrl();
|
String callBackUrl = onlyProperties.getLocalhostAddress() + onlyProperties.getCallBackUrl();
|
||||||
|
|
||||||
EditorConfig editorConfig = new EditorConfig(callBackUrl, mode);
|
EditorConfig editorConfig = new EditorConfig(callBackUrl, mode);
|
||||||
editorConfig.setFileCustomization(getFileCustomization(mode,clientType));
|
editorConfig.setFileCustomization(getFileCustomization(mode, clientType));
|
||||||
editorConfig.setFileUser(user);
|
editorConfig.setFileUser(user);
|
||||||
editorConfig.setPlugins(getPlugins());
|
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);
|
fileConfigDTO.setEditorConfig(editorConfig);
|
||||||
map.put("editorConfig", editorConfig);
|
map.put("editorConfig", editorConfig);
|
||||||
|
|
||||||
@@ -112,13 +117,13 @@ public class FileConfigFactory implements OnlyOfficeConfigFactory {
|
|||||||
return LoadConfigUtil.getCustomization();
|
return LoadConfigUtil.getCustomization();
|
||||||
}
|
}
|
||||||
|
|
||||||
private FileCustomization getFileCustomization(String mode,String clientType) {
|
private FileCustomization getFileCustomization(String mode, String clientType) {
|
||||||
FileCustomization customization = LoadConfigUtil.getCustomization();
|
FileCustomization customization = LoadConfigUtil.getCustomization();
|
||||||
if (mode != null && !(mode.trim()).equals("") && mode.equals("edit")) {
|
if (mode != null && !(mode.trim()).equals("") && mode.equals("edit")) {
|
||||||
customization.setAutosave(true);
|
customization.setAutosave(true);
|
||||||
}
|
}
|
||||||
customization.setMobileForceView(false);
|
customization.setMobileForceView(false);
|
||||||
if(clientType!=null&&clientType!=""&&"mobile".equals(clientType)){
|
if (clientType != null && clientType != "" && "mobile".equals(clientType)) {
|
||||||
customization.setMobileForceView(true);
|
customization.setMobileForceView(true);
|
||||||
}
|
}
|
||||||
return customization;
|
return customization;
|
||||||
|
|||||||
@@ -16,13 +16,14 @@ public interface SaveFileProcessor {
|
|||||||
void saveBeforeInitialization(Map<String, Object> map,byte[] bytes,String fileExtension) throws Exception;
|
void saveBeforeInitialization(Map<String, Object> map,byte[] bytes,String fileExtension) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* 存储onlyoffice文件信息
|
||||||
* @param map 文件元信息
|
* @param map 文件元信息
|
||||||
* @param file 文件
|
* @param file 文件
|
||||||
* @param changes 文件变动信息
|
* @param changes 文件变动信息
|
||||||
* @return 返回新的文件信息
|
* @param fileId 文件id
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
Map<String, Object> save(Map<String, Object> map,byte[] file, byte[] changes,String key);
|
Map<String, Object> save(Map<String, Object> map,byte[] file, byte[] changes,String fileId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存文件后进行自定义处理
|
* 保存文件后进行自定义处理
|
||||||
|
|||||||
@@ -77,8 +77,23 @@ public class FileHandlerImpl implements FileHandler {
|
|||||||
cache.set(user.getId() + "_" + id, key);
|
cache.set(user.getId() + "_" + id, key);
|
||||||
cache.set("getID_" + key, id);
|
cache.set("getID_" + key, id);
|
||||||
}
|
}
|
||||||
} else {//查看模式
|
} else {
|
||||||
key = id;
|
//查看模式
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -22,13 +22,13 @@ spring:
|
|||||||
datasource:
|
datasource:
|
||||||
type: com.alibaba.druid.pool.DruidDataSource
|
type: com.alibaba.druid.pool.DruidDataSource
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
url: jdbc:mysql://121.40.189.20:3306/onlyoffice?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai&useSSL=false
|
url: jdbc:mysql://121.40.189.20:3306/onlyoffice_test?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai&useSSL=false
|
||||||
username: root
|
username: root
|
||||||
password: YMzc157#
|
password: YMzc157#
|
||||||
redis:
|
redis:
|
||||||
host: 121.40.189.20
|
host: 121.40.189.20
|
||||||
port: 6389
|
port: 6389
|
||||||
database: 0
|
database: 1
|
||||||
|
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
# global-config:
|
# global-config:
|
||||||
@@ -45,13 +45,29 @@ spring:
|
|||||||
config:
|
config:
|
||||||
activate:
|
activate:
|
||||||
on-profile: dev
|
on-profile: dev
|
||||||
filepath: C:/onlyoffice/data/files
|
datasource:
|
||||||
serverhost: http://172.16.0.254
|
type: com.alibaba.druid.pool.DruidDataSource
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
url: jdbc:mysql://121.40.189.20:3306/onlyoffice_test?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai&useSSL=false
|
||||||
|
username: root
|
||||||
|
password: YMzc157#
|
||||||
|
filepath: /home/ruoyi/uploadPath/onlyoffice/data/files
|
||||||
|
serverhost: http://121.40.189.20
|
||||||
---
|
---
|
||||||
#生产环境属性配置
|
#生产环境属性配置
|
||||||
spring:
|
spring:
|
||||||
config:
|
config:
|
||||||
activate:
|
activate:
|
||||||
on-profile: prod
|
on-profile: prod
|
||||||
filepath: /onlyoffice/data/files
|
redis:
|
||||||
|
host: 121.40.189.20
|
||||||
|
port: 6389
|
||||||
|
database: 0
|
||||||
|
datasource:
|
||||||
|
type: com.alibaba.druid.pool.DruidDataSource
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
url: jdbc:mysql://121.40.189.20:3306/onlyoffice?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai&useSSL=false
|
||||||
|
username: root
|
||||||
|
password: YMzc157#
|
||||||
|
filepath: /home/ruoyi/uploadPath/onlyoffice/data/files
|
||||||
serverhost: http://121.40.189.20
|
serverhost: http://121.40.189.20
|
||||||
Reference in New Issue
Block a user