use of com.qiwenshare.file.util.FileModel in project qiwen-file by qiwenshare.
the class OfficeController method editOfficeFile.
@Operation(summary = "编辑office文件", description = "编辑office文件", tags = { "office" })
@ResponseBody
@RequestMapping(value = "/editofficefile", method = RequestMethod.POST)
public RestResult<Object> editOfficeFile(HttpServletRequest request, @RequestBody EditOfficeFileDTO editOfficeFileDTO, @RequestHeader("token") String token) {
RestResult<Object> result = new RestResult<>();
log.info("editOfficeFile");
try {
JwtUser loginUser = SessionUtil.getSession();
UserFile userFile = userFileService.getById(editOfficeFileDTO.getUserFileId());
String baseUrl = request.getScheme() + "://" + deploymentHost + ":" + port + request.getContextPath();
log.info("回调地址baseUrl:" + baseUrl);
FileModel file = new FileModel(userFile.getFileName() + "." + userFile.getExtendName(), editOfficeFileDTO.getPreviewUrl(), userFile.getUploadTime(), String.valueOf(loginUser.getUserId()), loginUser.getUsername(), "edit");
file.changeType(request.getParameter("mode"), "edit");
String query = "?type=edit&userFileId=" + userFile.getUserFileId() + "&token=" + token;
file.editorConfig.callbackUrl = baseUrl + "/office/IndexServlet" + query;
JSONObject jsonObject = new JSONObject();
jsonObject.put("file", file);
jsonObject.put("docserviceApiUrl", ConfigManager.GetProperty("files.docservice.url.site") + ConfigManager.GetProperty("files.docservice.url.api"));
jsonObject.put("reportName", userFile.getFileName());
result.setData(jsonObject);
result.setCode(200);
result.setMessage("编辑报告成功!");
} catch (Exception e) {
log.error(e.getMessage());
result.setCode(500);
result.setMessage("服务器错误!");
}
return result;
}
use of com.qiwenshare.file.util.FileModel in project qiwen-file by qiwenshare.
the class OfficeController method previewOfficeFile.
@Operation(summary = "预览office文件", description = "预览office文件", tags = { "office" })
@RequestMapping(value = "/previewofficefile", method = RequestMethod.POST)
@ResponseBody
public RestResult<Object> previewOfficeFile(HttpServletRequest request, @RequestBody PreviewOfficeFileDTO previewOfficeFileDTO, @RequestHeader("token") String token) {
RestResult<Object> result = new RestResult<>();
try {
JwtUser loginUser = SessionUtil.getSession();
UserFile userFile = userFileService.getById(previewOfficeFileDTO.getUserFileId());
String baseUrl = request.getScheme() + "://" + deploymentHost + ":" + port + request.getContextPath();
FileModel file = new FileModel(userFile.getFileName() + "." + userFile.getExtendName(), previewOfficeFileDTO.getPreviewUrl(), userFile.getUploadTime(), String.valueOf(loginUser.getUserId()), loginUser.getUsername(), "view");
String query = "?type=show&token=" + token;
file.editorConfig.callbackUrl = baseUrl + "/office/IndexServlet" + query;
JSONObject jsonObject = new JSONObject();
jsonObject.put("file", file);
jsonObject.put("docserviceApiUrl", ConfigManager.GetProperty("files.docservice.url.site") + ConfigManager.GetProperty("files.docservice.url.api"));
jsonObject.put("reportName", userFile.getFileName());
result.setData(jsonObject);
result.setCode(200);
result.setMessage("获取报告成功!");
} catch (Exception e) {
log.error(e.getMessage());
result.setCode(500);
result.setMessage("服务器错误!");
}
return result;
}
Aggregations