|
@@ -15,9 +15,7 @@ import com.doc.common.enums.BusinessType;
|
|
|
import com.doc.common.utils.FileContentUtils;
|
|
|
import com.doc.common.utils.SecurityUtils;
|
|
|
import com.doc.common.utils.poi.ExcelUtil;
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
-import io.swagger.annotations.ApiParam;
|
|
|
+import io.swagger.annotations.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.data.elasticsearch.NoSuchIndexException;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
@@ -61,26 +59,14 @@ public class DocInfoController extends BaseController {
|
|
|
* @param file
|
|
|
* @return
|
|
|
*/
|
|
|
- @ApiOperation("上传文件")
|
|
|
+ @ApiOperation("文件上传-单文件")
|
|
|
@PostMapping("/upload")
|
|
|
public AjaxResult uploadFile(@ApiParam(value = "文件", required = true) @RequestPart(value = "file") MultipartFile file,
|
|
|
@ApiParam(value = "空间ID", required = true) @RequestParam Long spaceId,
|
|
|
@ApiParam(value = "目录ID", required = true) @RequestParam Long dirId) {
|
|
|
try {
|
|
|
DocumentVO vo = mongoService.uploadFile(file);
|
|
|
- DocInfo docInfo = new DocInfo();
|
|
|
- docInfo.setSpaceId(spaceId);
|
|
|
- docInfo.setDirId(dirId);
|
|
|
- docInfo.setFileId(vo.getFileId());
|
|
|
- docInfo.setFileName(vo.getFileName());
|
|
|
- docInfo.setFileSize(vo.getFileSize());
|
|
|
- docInfo.setFileType(vo.getSuffix());
|
|
|
- docInfo.setCreateBy(SecurityUtils.getUsername());
|
|
|
- docInfoService.insertDocInfo(docInfo);
|
|
|
-
|
|
|
- DocumentVO documentVO = mongoService.downloadFile(vo.getFileId());
|
|
|
- insertEs(documentVO.getData(), docInfo.getFileType(), docInfo.getDocId(), spaceId);
|
|
|
-
|
|
|
+ process(vo, spaceId, dirId);
|
|
|
return success();
|
|
|
} catch (Exception e) {
|
|
|
log.error("文件上传失败:", e);
|
|
@@ -94,16 +80,44 @@ public class DocInfoController extends BaseController {
|
|
|
* @param files
|
|
|
* @return
|
|
|
*/
|
|
|
+ @ApiOperation("文件上传-多文件")
|
|
|
@PostMapping("/uploadFiles")
|
|
|
- public AjaxResult uploadFile(@RequestParam(value = "files") List<MultipartFile> files) {
|
|
|
+ public AjaxResult uploadFile(@ApiParam(value = "文件", required = true) @RequestPart(value = "files") List<MultipartFile> files,
|
|
|
+ @ApiParam(value = "空间ID", required = true) @RequestParam Long spaceId,
|
|
|
+ @ApiParam(value = "目录ID", required = true) @RequestParam Long dirId) {
|
|
|
try {
|
|
|
- return success(mongoService.uploadFiles(files));
|
|
|
+ mongoService.uploadFiles(files).stream().forEach(vo -> {
|
|
|
+ process(vo, spaceId, dirId);
|
|
|
+ });
|
|
|
+ return success();
|
|
|
} catch (Exception e) {
|
|
|
return error(e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 文件上传之后的操作
|
|
|
+ *
|
|
|
+ * @param vo 上传对象
|
|
|
+ * @param spaceId 空间ID
|
|
|
+ * @param dirId 目录ID
|
|
|
+ */
|
|
|
+ private void process(DocumentVO vo, Long spaceId, Long dirId) {
|
|
|
+ DocInfo docInfo = new DocInfo();
|
|
|
+ docInfo.setSpaceId(spaceId);
|
|
|
+ docInfo.setDirId(dirId);
|
|
|
+ docInfo.setFileId(vo.getFileId());
|
|
|
+ docInfo.setFileName(vo.getFileName());
|
|
|
+ docInfo.setFileSize(vo.getFileSize());
|
|
|
+ docInfo.setFileType(vo.getSuffix());
|
|
|
+ docInfo.setCreateBy(SecurityUtils.getUsername());
|
|
|
+ docInfoService.insertDocInfo(docInfo);
|
|
|
+
|
|
|
+ DocumentVO documentVO = mongoService.downloadFile(vo.getFileId());
|
|
|
+ insertEs(documentVO.getData(), docInfo.getFileType(), docInfo.getDocId(), spaceId);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 文件下载
|
|
|
*
|
|
|
* @param fileId fileId
|
|
@@ -146,9 +160,70 @@ public class DocInfoController extends BaseController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 文件移动
|
|
|
+ */
|
|
|
+ @ApiOperation("文件移动")
|
|
|
+ @GetMapping("/move")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "docId", value = "文件ID", required = true),
|
|
|
+ @ApiImplicitParam(name = "spaceId", value = "空间ID"),
|
|
|
+ @ApiImplicitParam(name = "dirId", value = "新目录ID", required = true)
|
|
|
+ })
|
|
|
+ public AjaxResult move(Long docId, Long dirId) {
|
|
|
+ DocInfo info = docInfoService.selectDocInfoByDocId(docId);
|
|
|
+ info.setDirId(dirId);
|
|
|
+
|
|
|
+ info.setUpdateBy(SecurityUtils.getUsername());
|
|
|
+ docInfoService.updateDocInfo(info);
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 复制文件
|
|
|
+ */
|
|
|
+ @ApiOperation("文件复制")
|
|
|
+ @GetMapping("/copy")
|
|
|
+ @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);
|
|
|
+ info.setDocId(null);
|
|
|
+ info.setSpaceId(spaceId);
|
|
|
+ info.setDirId(dirId);
|
|
|
+
|
|
|
+ docInfoService.insertDocInfo(info);
|
|
|
+
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 复制文件
|
|
|
+ */
|
|
|
+ @ApiOperation("文件重命名")
|
|
|
+ @GetMapping("/rename")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "docId", value = "文件ID", required = true),
|
|
|
+ @ApiImplicitParam(name = "name", value = "新文件名", required = true)
|
|
|
+ })
|
|
|
+ public AjaxResult rename(Long docId, String name) {
|
|
|
+ DocInfo info = new DocInfo();
|
|
|
+ info.setDocId(docId);
|
|
|
+ info.setFileName(name);
|
|
|
+
|
|
|
+ info.setUpdateBy(SecurityUtils.getUsername());
|
|
|
+
|
|
|
+ docInfoService.insertDocInfo(info);
|
|
|
+
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 查询文件基本信息表列表
|
|
|
*/
|
|
|
- @ApiOperation("查询文件基本信息表列表")
|
|
|
+// @ApiOperation("文件列表")
|
|
|
//@PreAuthorize("@ss.hasPermi('biz:info:list')")
|
|
|
@GetMapping("/list")
|
|
|
public TableDataInfo list(DocInfo docInfo) {
|
|
@@ -158,9 +233,23 @@ public class DocInfoController extends BaseController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 查询文件基本信息表列表
|
|
|
+ */
|
|
|
+ @ApiOperation("根据目录ID查询文件列表")
|
|
|
+ //@PreAuthorize("@ss.hasPermi('biz:info:list')")
|
|
|
+ @GetMapping("/list/{dirId}")
|
|
|
+ public TableDataInfo list4dir(@PathVariable("dirId") Long dirId) {
|
|
|
+ startPage();
|
|
|
+ DocInfo docInfo = new DocInfo();
|
|
|
+ docInfo.setDirId(dirId);
|
|
|
+ List<DocInfo> list = docInfoService.selectDocInfoList(docInfo);
|
|
|
+ return getDataTable(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 导出文件基本信息表列表
|
|
|
*/
|
|
|
- @ApiOperation("导出文件基本信息表列表")
|
|
|
+// @ApiOperation("导出文件基本信息表列表")
|
|
|
//@PreAuthorize("@ss.hasPermi('biz:info:export')")
|
|
|
@Log(title = "文件基本信息表", businessType = BusinessType.EXPORT)
|
|
|
@PostMapping("/export")
|
|
@@ -173,7 +262,7 @@ public class DocInfoController extends BaseController {
|
|
|
/**
|
|
|
* 获取文件基本信息表详细信息
|
|
|
*/
|
|
|
- @ApiOperation("获取文件基本信息表详细信息")
|
|
|
+ @ApiOperation("文件详细信息")
|
|
|
//@PreAuthorize("@ss.hasPermi('biz:info:query')")
|
|
|
@GetMapping(value = "/{docId}")
|
|
|
public AjaxResult getInfo(@PathVariable("docId") Long docId) {
|
|
@@ -183,7 +272,7 @@ public class DocInfoController extends BaseController {
|
|
|
/**
|
|
|
* 新增文件基本信息表
|
|
|
*/
|
|
|
- @ApiOperation("新增文件基本信息表")
|
|
|
+// @ApiOperation("新增文件基本信息表")
|
|
|
//@PreAuthorize("@ss.hasPermi('biz:info:add')")
|
|
|
@Log(title = "文件基本信息表", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
@@ -194,7 +283,7 @@ public class DocInfoController extends BaseController {
|
|
|
/**
|
|
|
* 修改文件基本信息表
|
|
|
*/
|
|
|
- @ApiOperation("修改文件基本信息表")
|
|
|
+// @ApiOperation("修改文件基本信息表")
|
|
|
//@PreAuthorize("@ss.hasPermi('biz:info:edit')")
|
|
|
@Log(title = "文件基本信息表", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
@@ -207,7 +296,7 @@ public class DocInfoController extends BaseController {
|
|
|
/**
|
|
|
* 删除文件基本信息表
|
|
|
*/
|
|
|
- @ApiOperation("删除文件基本信息表")
|
|
|
+ @ApiOperation("文件删除")
|
|
|
//@PreAuthorize("@ss.hasPermi('biz:info:remove')")
|
|
|
@Log(title = "文件基本信息表", businessType = BusinessType.DELETE)
|
|
|
@DeleteMapping("/{docIds}")
|