Parcourir la source

解决复制时重命名相关问题

wukai il y a 1 an
Parent
commit
0f624e3650

+ 11 - 10
doc-biz/src/main/java/com/doc/biz/controller/DocInfoController.java

@@ -15,6 +15,7 @@ import com.doc.common.core.domain.AjaxResult;
 import com.doc.common.core.page.TableDataInfo;
 import com.doc.common.enums.BusinessType;
 import com.doc.common.enums.EventLevel;
+import com.doc.common.utils.DateUtils;
 import com.doc.common.utils.SecurityUtils;
 import com.doc.common.utils.bean.BeanUtils;
 import com.doc.common.utils.file.FileUtils;
@@ -64,7 +65,7 @@ public class DocInfoController extends BaseController {
      * @return
      */
     @ApiOperation("文件上传-单文件")
-    @Log(title = "文件基本信息表", businessType = BusinessType.INSERT,eventLevel = EventLevel.MIDDLE)
+    @Log(title = "文件基本信息表", businessType = BusinessType.INSERT, eventLevel = EventLevel.MIDDLE)
     @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 {
@@ -85,7 +86,7 @@ public class DocInfoController extends BaseController {
      */
     @ApiOperation("文件上传-多文件")
     @PostMapping("/uploadFiles")
-    @Log(title = "文件基本信息表", businessType = BusinessType.INSERT,eventLevel = EventLevel.MIDDLE)
+    @Log(title = "文件基本信息表", businessType = BusinessType.INSERT, eventLevel = EventLevel.MIDDLE)
     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 {
             mongoService.uploadFiles(files).stream().forEach(vo -> {
@@ -126,7 +127,7 @@ public class DocInfoController extends BaseController {
             @ApiImplicitParam(name = "spaceId", value = "空间ID", required = true),
             @ApiImplicitParam(name = "dirId", value = "目录ID", required = true)
     })
-    @Log(title = "文件基本信息表", businessType = BusinessType.INSERT,eventLevel = EventLevel.MIDDLE)
+    @Log(title = "文件基本信息表", businessType = BusinessType.INSERT, eventLevel = EventLevel.MIDDLE)
     public AjaxResult create(Long spaceId, Long dirId, String type) {
         try {
             String filePath = "";
@@ -166,7 +167,7 @@ public class DocInfoController extends BaseController {
      */
     @ApiOperation("文件移动")
     @GetMapping("/move")
-    @Log(title = "文件基本信息表", businessType = BusinessType.UPDATE,eventLevel = EventLevel.MIDDLE)
+    @Log(title = "文件基本信息表", businessType = BusinessType.UPDATE, eventLevel = EventLevel.MIDDLE)
     @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);
@@ -182,7 +183,7 @@ public class DocInfoController extends BaseController {
      */
     @ApiOperation("文件复制")
     @GetMapping("/copy")
-    @Log(title = "文件基本信息表", businessType = BusinessType.INSERT,eventLevel = EventLevel.MIDDLE)
+    @Log(title = "文件基本信息表", businessType = BusinessType.INSERT, eventLevel = EventLevel.MIDDLE)
     @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);
@@ -198,7 +199,7 @@ public class DocInfoController extends BaseController {
         info.setDocId(null);
         info.setSpaceId(spaceId);
         info.setDirId(dirId);
-
+        info.setFileName(info.getFileName() + "-副本-" + DateUtils.dateTimeNow());
         docInfoService.insertDocInfo(info);
 
         return success();
@@ -210,7 +211,7 @@ public class DocInfoController extends BaseController {
      */
     @ApiOperation("文件重命名")
     @GetMapping("/rename")
-    @Log(title = "文件基本信息表", businessType = BusinessType.UPDATE,eventLevel = EventLevel.MIDDLE)
+    @Log(title = "文件基本信息表", businessType = BusinessType.UPDATE, eventLevel = EventLevel.MIDDLE)
     @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();
@@ -320,7 +321,7 @@ public class DocInfoController extends BaseController {
      */
 //    @ApiOperation("新增文件基本信息表")
     //@PreAuthorize("@ss.hasPermi('biz:info:add')")
-    @Log(title = "文件基本信息表", businessType = BusinessType.INSERT,eventLevel = EventLevel.MIDDLE)
+    @Log(title = "文件基本信息表", businessType = BusinessType.INSERT, eventLevel = EventLevel.MIDDLE)
     @PostMapping
     public AjaxResult add(@RequestBody DocInfo docInfo) {
         return toAjax(docInfoService.insertDocInfo(docInfo));
@@ -331,7 +332,7 @@ public class DocInfoController extends BaseController {
      */
 //    @ApiOperation("修改文件基本信息表")
     //@PreAuthorize("@ss.hasPermi('biz:info:edit')")
-    @Log(title = "文件基本信息表", businessType = BusinessType.UPDATE,eventLevel = EventLevel.MIDDLE)
+    @Log(title = "文件基本信息表", businessType = BusinessType.UPDATE, eventLevel = EventLevel.MIDDLE)
     @PutMapping
     public AjaxResult edit(@RequestBody DocInfo docInfo) {
         docInfo.setUpdateBy(SecurityUtils.getUsername());
@@ -343,7 +344,7 @@ public class DocInfoController extends BaseController {
      */
     @ApiOperation("文件删除")
     //@PreAuthorize("@ss.hasPermi('biz:info:remove')")
-    @Log(title = "文件基本信息表", businessType = BusinessType.DELETE,eventLevel = EventLevel.MIDDLE)
+    @Log(title = "文件基本信息表", businessType = BusinessType.DELETE, eventLevel = EventLevel.MIDDLE)
     @DeleteMapping("/{docIds}")
     public AjaxResult remove(@PathVariable Long[] docIds) {
         for (Long docId : docIds) {

+ 1 - 1
doc-biz/src/main/java/com/doc/biz/service/impl/DocInfoServiceImpl.java

@@ -116,7 +116,7 @@ public class DocInfoServiceImpl implements IDocInfoService {
         List list = selectDocInfoList(query);
         if (list.size() > 0) {
             String fileName = docInfo.getFileName();
-            fileName = DateUtils.dateTimeNow() + "-" + fileName;
+            fileName = fileName + "-" + DateUtils.dateTimeNow();
             docInfo.setFileName(fileName);
         }