1、环境搭建:暂略

2、代码

后端

onlyoffice协同办公后端:
实体类:文件表实体类:public class  File implements Serializable{private static final long serialVersionUID = 1L;private String fileId;private String fileName;private String crateTime;private String updateTime;private String createBy;private String updateBy;private String isDel;}历史记录表实体类:public class FileHistoryLog extends BaseEntity{private static final long serialVersionUID = 1L;private String historyFileId;private String fileId;private String lastSave; //最后保存事件private String notmodified; //最后不修改private String changesUrl;//修改记录zip包路径private String serverVersion; //服务器版本private String changes; //用户修改记录json数组private String actions;//共同编辑用户json数组private String key; //当前版本号private String url; //当前最新记录private String users; //用户数组字符串private String stauts;private String realUrl;  //最新版本文件下载路径private String isDel;private String previousKey;  //之前版本的keyprivate String previousUrl; //之前版本的url}onlyoffice的通用请求处理@RestController@RequestMapping("/onlyoffice/data")public class OnlyOfficeDataController{private final OnlyOfficeUserDocumentService cods;private final TokenService tokenService;@Autowiredpublic OblyOfficeDataController(OnlyOfficeUserDocumentService cods,TokenService tokenService){this.cods = code;this.tokenService= tokenService;}//根据文件id和当前登录用户,查询用户是否具有权限编辑,并返回文件相关信息@GetMapping("/selectFileInfoByFileId")public Response<File> selectFileInfoByFileId(@ModelAttribute File data,HttpServletRequest request){LoginUser user = tokenSerivce.getLoginUser(request);data.setUserId(user.getUser.getUserId());if(StringUtils.isEmpty(data.getFileId()){//前端传递过来的文件id为空return Response.error(ResponseEnum.ONLY_OFFICE_FILEID_FAIL);}File file = cods.selectFileInfoByFileId(data); //查询前端传递过来的文件id查询文件信息file.setUserId(user.getUser.getUserId);file.setNickName(user.getUser.getNickName);return Response.success(file);}}@RestController@RequestMapping("/onlyoffice/online")public class OnlyOfficeOnlineController{@Autowiredprivate OnlyOfficeHistoryLogService cohl;@Autowiredprivate OnlyOfficeUserDocumentService cods;@Autowiredprivate IMcoMeetFileService mcoMeetFileService;@Autowiredprivate IMcoOperationHistoryService mcoOpereationHistoryService;@GetMapping("/getfile")public void getFile(String fileName,HttpServletResponse response,HttpServletRequest request){try{response.setCharacterEncoding("utf-8");response.setContentType("text/plain");FileUtils.writeBytes(ImwConfig.getProfile()+fileName,response.getOutputStream());}catch(UnsupportedEncodingException e){e.printStackTrace();}catch(IOException e){e.printStackTrace();}}}@RequestMapping("/downloadfile")public void fileDownloads(HttpServletRequest request,HttpServletResponse response,OFHistoryLog log) throws IOException{PrintWriter writer = null;FileOutputStream out = null;FileOutputStream outz = null;InputStream stream = null;InputStream streamz = null;String realPath = "";String hisZip = "";try{writer = response.getWriter();Scanner scanner = new Scanner(request.getInputStream()).useDelimiter("\\A");String body = scanner.hasNext()?scanner.next():"";JSONObject jsonObj = JSONObject.parseObject(body);if((Integer)jsonObj.get("status")==2){String key = "XT_"+DateUtils.getNowDate().getTime();String downlaodUri = (String)jsonObj.get("url"); //保存变更后文件String changeUrl = (String) jsonObj.get("changeurl") //保存文件的修改记录//文档编辑完成,现在开始保存编辑后的文档,其下载地址为downloadUriString fileName = request.getParameter("filename");URL url = new URL(downloadUri);URL changeUrlZ = new URL(changesUrl);java.net.HttpURLConnection connection = (java.net.HttpURLConnection) url.openConnection();java.net.HttpURLConnection connectionz = (java.net.HttpURLConnection)changeUrlz.openConnection();stream = connection.getInputStream();streamz = connectionz.getInputStream();int s = downloadUri.loatIndexOf(".");String suff = downloadUri.substring(s,downloadUri.length());realPath = "onlyoffice/his/"+key +suff;hisZip = "onlyoffice/his/"+key+".zip";try{File savedFile = new File(ImwConfig.getProfile()+realPath);File zip = new File(ImwConfig.getProfile()+hisZip);if(!zip.exists()){File fileparent = new File(zip.getParent());fileparent.mkdirs();}if(!savedFile.exists()){File fileparent = new File(zip.getParent());fileparent.mkdirs();}out = new FileOutputStream(savedFile);outz = new FileOutputStream(zip);int read ;final byte[] bytes = new byte[1024];while((read=stream.read(bytes)!=-1)){out.write(bytes,0,read);}out.flush();int reads;final byte[] bytesz = new byte[1024];while((read=streamz.read(bytesz))!=-1){outz.write(bytesz,0,reads);}outz.flush();connection.disconnect();//写入完成之后,执行保存数据库逻辑log.setRealUrl(realPath);log.setChangesUrl(hisZip);log.setUrl(realPath);....}}}catch(IOException e){e.printStackTrace();}writer.write("{\"error\":0}");}//通用下载请求GetMapping("/common/downlaod")public void fileDownload(String fileName,Boolean delete,HttpServletResponse response,HttpServletRequest request){String localPath = ImwConfig.getAvatarPath();String downloadPath = localPath + StringUtils.substringAfter(filename,Constants.JWT_AVATAR);try{String downloadName = StringUtils.substringAfterLast(fileName,"/");response.setCharacterEncoding("utf-8");response.setContentType("multipart/form-data");response.setHeader("Content-Disposition","attachment;fileName="+FileUtils.setFileDownloadHeader(request,downlaodName));FileUtils.writeBytes(fileName,reponse.getOutputStream());}catch(UnsupportedEncodingException e){e.printStackTrace();}catch(IOException e){e.printStackTrace();}}

前端

//onlyOffice前端onlyOffice.vue<template><div class="content"><div id="placeholder" class="nav"></div></div></template><script>import webpack from "../vue.config";import {selectFileInfoByFileId} from "@/api/onlyOffice";export default{name:"onlyOffice",data(){return{docEditor:"",userInfo:{},historyz:[],onlyOfficeConfig:{},};},created(){this.$nextTick(()=>{let ids = ''let fal = ''let params = this.$route.queryif(params&&params.id){ids = window.atob(param.id).split('-')[1]fla = window.atob(param.flag).split('-')[1]}else{ids = localStorge.getItem('id')fla = localStorge.getItem('will')}let dataz = {Id:ids,will:fla};//调用接口查询文件历史版本数据,查询用户是否拥有这个文档,鉴权返回数据操作selectFileInfoByFileId(dataz).then(response=>{if(response.code==200){let data = response.data;let edit = false;if(dataz.will=='t'){edit = true;}let s =(data.path).lastIndexOf('.')let reaType = (data.path).substring(s+1)this.onlyOfficeConfig['realType'] = realTypethis.onlyOfficeConfig['fileType'] = data.fileTypethis.onlyOfficeConfig['edit'] = editthis.onlyOfficeConfig['userId'] = data.userId.....data.listof.map(items=>{items["user"]={id:items.users,name:items.userName};items["created"] = item.lastSave;items.changes = JSON.parse(item.changes);items.actions = JSON.parse(item.actions);});this.historyz = data.listof;this.baseUrl = webpack.devServlet.proxy[process.env.VUE_APP_BASE_API].target;this.initOnlyOffice();}})})},methods:{initOnlyOffice(){if(!this.historyz){this.onRequestHistory = null;}this.docEditor = new DocsAPI.DocEditor("placeholder",{events:{onRequestHistoryData:this.onRequestHistoryData,onRequestHistory:this.onRequestHistory,onRequestHistoryClose:this.onRequestHistoryClose},document:{fileType:this.onlyOfficeConfig.realType,key:this.onlyOfficeConfig.key,desc:this.onlyOfficeConfig.fileTitle,title:this.onlyOfficeConfig.fileName,permissions:{comment:true,download:true,edit:this.onlyOfficeConfig.edit,fillForms:true,print:true,review:this.onlyOfficeConfig.edit}},url:this.baseUrl+"/onlyOffice/online/getFile?fileName="+encodeURI(this.onlyOfficeConfig.path)documentType:this.onlyOfficeConfig.fileType,lang:"zh-CN",location:"",region:"zh",width:"96%",editorConfig:{callbackUrl:this.baseUrl+"onlyOffice/online/downloadfile?priviousKey="+this.onlyOfficeConfig.key+"&previousUrl="+this.onlyOfficeConfig.path+"&userName="+this.onlyOfficeConfig.name+"&meetFileId="+this.onlyOfficeConfig.meetFIleId+"&users="+this.onlyOfficeConfig.userId,lang:"zh-CN",user:{id:this.onlyOfficeCOnfig.userId,name:this.onlyOfficeCOnfig.name}}})},onReqestHistoryData(event){let version = event.data;let str = {};if(this.historyz){this.historyz.map(item=>{if(item.version==version){str["changesUrl"]=this.baseUrl+"onlyOffice/online/getFile?fileName="+encodeURI(item.changeUrl);str["key"] = item.key;str["url"] = this.baseUrl+"onlyOffice/online/getFile?fileName="+encodeURI(item.realUrl);str["previous"]["key"] = item.previousKey;str["previous"]["url"] = this.baseUrl+"onlyOffice/online/getFile?fileName="+encodeURI(item.previousUrl);}})this.docEditor.setHistoryData(str)}},onRequestHistory(){if(this.historyz){this.docEditor.refreshHistory({currentVersion:8,history:this.historyz})}},onRequestHistoryClose(){document.location.reload();},}}</script>

java+vue实现onlyoffice协同办公相关推荐

  1. 致远a8 java,致远A8协同办公系统poc/seeyon 0day

    网上的poc已经满天飞了,看见大佬们分享的赶紧尝试一下 title="致远A8+协同管理软件 V7.0SP3"&&country="CN" 寻找 ...

  2. 非常棒的开源协同办公OA项目,收藏了!

      大家好,我是为广大程序员兄弟操碎了心的小编,每天推荐一个小工具/源码,装满你的收藏夹,每天分享一个小技巧,让你轻松节省开发效率,实现不加班不熬夜不掉头发,是我的目标!   最近有些读者朋友私信小编 ...

  3. 基于Docker搭建DzzOffice与OnlyOffice线上协同办公服务器

    简介   记录一下在debian服务器上搭建线上协同办公服务器过程中的遇到的问题,避免后续安装过程中出现卡壳的情况. 安装数据库   在docker官方镜像源上下载mysql数据库镜像,下载使用时My ...

  4. springboot毕设项目协同过滤推荐的餐厅点菜系统b2033(java+VUE+Mybatis+Maven+Mysql)

    springboot毕设项目协同过滤推荐的餐厅点菜系统b2033(java+VUE+Mybatis+Maven+Mysql) 项目运行 环境配置: Jdk1.8 + Tomcat8.5 + Mysql ...

  5. springboot毕设项目在线智能办公系统bxl9i(java+VUE+Mybatis+Maven+Mysql)

    springboot毕设项目在线智能办公系统bxl9i(java+VUE+Mybatis+Maven+Mysql) 项目运行 环境配置: Jdk1.8 + Tomcat8.5 + Mysql + HB ...

  6. Java开源协同办公OA项目:自己搭建三个办公必备小功能!

    今天要给大家介绍的是Java开源协同办公OA项目:O2OA应用市场中的三个小功能,分别是值班表.培训申请.加班申请. 一.值班表 为了确保政企事业单位的安全和正常公务以及突发事件的处理,值班是个不可忽 ...

  7. Java开源协同办公开发平台:报销申请如何使用

    企业中的财务管理,可以说是企业的经济命脉,但是日常管理中的采购申请.差旅报销等等费用报销的审批非常繁多琐碎,许多的企业都选择了使用OA系统来实现财务规范化的管理. O2OA报销申请是使用平台能力自定义 ...

  8. java计算机毕业设计分时共享办公系统MyBatis+系统+LW文档+源码+调试部署

    java计算机毕业设计分时共享办公系统MyBatis+系统+LW文档+源码+调试部署 java计算机毕业设计分时共享办公系统MyBatis+系统+LW文档+源码+调试部署 本源码技术栈: 项目架构:B ...

  9. 致力协同办公oa系统服务器设置,致力协同办公oa系统安装手册新.pdf

    致力协同办公oa系统安装手册新 致力协同办公 OA 系统 V7.0 致力协同办公 OA 系统 V7.0--安装手册 欢迎安装使用致力协同办公 OA 系统,当您按照下述方法完成安装过程后,即可体验本 系 ...

最新文章

  1. Asp.net中时间格式化的几种方法
  2. c# redis hashid如何设置过期时间_Redis中Key过期策略amp;淘汰机制
  3. GCJ 2009 Round1C C Bribe the Prisoners
  4. Windows 下端口被占用
  5. angularjs1-1
  6. ec200s 方案 移远_移远4GCat1无线通讯模块EC200S
  7. Java程序员需要掌握的计算机底层知识(三):进程、线程、纤程、中断
  8. mysql 连接 内存溢出_mysql - MySQL中止连接未知错误 - 堆栈内存溢出
  9. 黑历史有救了,淘宝可以改账号名了!网友:终于可以“重新做人”了
  10. docker 打包部署 python项目_Docker如何部署Python项目的实现详解
  11. AndroidTelephony学习大纲
  12. java剑指offer_剑指offer题目java实现
  13. c语言糖果游戏,幼儿园小班糖果游戏教案
  14. [USACO 6.4.2] Electric Fences
  15. 人人都是产品经理 2.0
  16. zabbix mysql安装配置_Zabbix安装图解教程 | 系统运维
  17. 最小二乘支持向量机预测matlab实现,最小二乘支持向量机MATLAB程序,可分多类
  18. 腾讯入股合作金融云,花费4亿元获长亮科技7.14%股份
  19. ZZULIOJ 1924: 宣传墙 (dp)
  20. 字谜 大小写重复全排列问题

热门文章

  1. 微信小程序可以打开公众号文章
  2. windows 10环境下docker 部署RocketMq和RocketMq-Consol 控制台
  3. 大数据下机械智能诊断的机遇与挑战,阅读文献系列(一)
  4. matlab批量处理excel(CSV)文件数据
  5. dql聚合函数_sql聚合函数有哪些
  6. 日本最惨数学天才!37岁裸辞,房子被政府没收,向全村人乞讨,一家五口只能吃野菜.........
  7. 爬虫-百度安全验证-图片旋转验证-深度学习解决方案
  8. 戴尔7060安装win10系统教程
  9. 全景制作教程:如何利用Pano2VR进行补天补地?
  10. 基于android手机实时监控ipcam视频之一:RTSP