|
|
@@ -2,12 +2,14 @@ package com.doc.biz.controller;
|
|
|
|
|
|
import com.doc.biz.domain.DocDir;
|
|
|
import com.doc.biz.domain.DocInfo;
|
|
|
+import com.doc.biz.domain.DocRecent;
|
|
|
import com.doc.biz.domain.DocSpace;
|
|
|
import com.doc.biz.service.*;
|
|
|
import com.doc.biz.vo.DocInfoVO;
|
|
|
import com.doc.biz.vo.DocumentVO;
|
|
|
import com.doc.common.annotation.Log;
|
|
|
import com.doc.common.config.EsConfig;
|
|
|
+import com.doc.common.constant.Constants;
|
|
|
import com.doc.common.core.controller.BaseController;
|
|
|
import com.doc.common.core.domain.AjaxResult;
|
|
|
import com.doc.common.core.page.TableDataInfo;
|
|
|
@@ -26,10 +28,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.InputStream;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 文件基本信息表Controller
|
|
|
@@ -181,13 +180,18 @@ public class DocInfoController extends BaseController {
|
|
|
@ApiImplicitParams({@ApiImplicitParam(name = "docId", value = "文件ID", required = true), @ApiImplicitParam(name = "spaceId", value = "空间ID"), @ApiImplicitParam(name = "dirId", value = "新目录ID", required = true)})
|
|
|
public AjaxResult copy(Long docId, Long spaceId, Long dirId) {
|
|
|
DocInfo info = docInfoService.selectDocInfoByDocId(docId);
|
|
|
-
|
|
|
- DocumentVO vo = mongoService.copy(info.getFileId());
|
|
|
+ String ext = info.getFileType();
|
|
|
+ //因为数据库存的是带 . 的,所以要先截取掉这个 .
|
|
|
+ ext = ext.substring(1);
|
|
|
+ if (Arrays.asList(Constants.ALLOW_EDIT).contains(ext)) {
|
|
|
+ //判断是否 onlyoffice允许的可编辑文件格式,如果是,则需要复制一份,如果不是就不管
|
|
|
+ DocumentVO vo = mongoService.copy(info.getFileId());
|
|
|
+ info.setFileId(vo.getFileId());
|
|
|
+ }
|
|
|
|
|
|
info.setDocId(null);
|
|
|
info.setSpaceId(spaceId);
|
|
|
info.setDirId(dirId);
|
|
|
- info.setFileId(vo.getFileId());
|
|
|
|
|
|
docInfoService.insertDocInfo(info);
|
|
|
|
|
|
@@ -359,20 +363,27 @@ public class DocInfoController extends BaseController {
|
|
|
* 文件下载
|
|
|
*/
|
|
|
@ApiOperation("文件预览")
|
|
|
- @GetMapping("/access/{fileId}")
|
|
|
- public ResponseEntity<Object> access(@PathVariable(name = "fileId") String fileId) {
|
|
|
-
|
|
|
- recentService.insertDocRecent(SecurityUtils.getUserId(), fileId);
|
|
|
+ @GetMapping("/access/{docId}")
|
|
|
+ public ResponseEntity<Object> access(@PathVariable(name = "docId") Long docId) {
|
|
|
|
|
|
- return mongoService.download(fileId, false);
|
|
|
+ DocInfo info = docInfoService.selectDocInfoByDocId(docId);
|
|
|
+ //插入最近文件
|
|
|
+ DocRecent recent = new DocRecent();
|
|
|
+ recent.setIsFolder("N");
|
|
|
+ recent.setOwner(SecurityUtils.getUserId());
|
|
|
+ recent.setRelaId(info.getDocId());
|
|
|
+ recentService.insertDocRecent(recent);
|
|
|
+
|
|
|
+ return mongoService.download(info.getFileId(), false);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 文件下载
|
|
|
*/
|
|
|
@ApiOperation("文件下载")
|
|
|
- @GetMapping("/download/{fileId}")
|
|
|
- public ResponseEntity<Object> download(@PathVariable(name = "fileId") String fileId) {
|
|
|
- return mongoService.download(fileId, true);
|
|
|
+ @GetMapping("/download/{docId}")
|
|
|
+ public ResponseEntity<Object> download(@PathVariable(name = "docId") Long docId) {
|
|
|
+ DocInfo info = docInfoService.selectDocInfoByDocId(docId);
|
|
|
+ return mongoService.download(info.getFileId(), true);
|
|
|
}
|
|
|
}
|