Browse Source

最近文件处理

wukai 2 năm trước cách đây
mục cha
commit
24fb015bfb

+ 11 - 12
doc-biz/src/main/java/com/doc/biz/controller/DocDirController.java

@@ -171,14 +171,16 @@ public class DocDirController extends BaseController {
     @GetMapping("/list")
     public AjaxResult list(DocDir docDir) {
         List<DocDir> list = docDirService.selectDocDirList(docDir);
-        /**
-         * 插入最近访问记录
-         */
-        DocRecent recent = new DocRecent();
-        recent.setIsFolder("Y");
-        recent.setOwner(SecurityUtils.getUserId());
-        recent.setRelaId(docDir.getParentId());
-        recentService.insertDocRecent(recent);
+        DocDir dir = docDirService.selectDocDirByDirId(docDir.getParentId());
+        if (dir.getParentId() != 0) {
+            //如果不是顶层目录
+            //插入最近访问记录
+            DocRecent recent = new DocRecent();
+            recent.setIsFolder("Y");
+            recent.setOwner(SecurityUtils.getUserId());
+            recent.setRelaId(dir.getDirId());
+            recentService.insertDocRecent(recent);
+        }
 
         return success(list);
     }
@@ -236,10 +238,7 @@ public class DocDirController extends BaseController {
     @ApiOperation("重命名")
     @Log(title = "文档目录管理", businessType = BusinessType.UPDATE)
     @GetMapping("/rename")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "dirId", value = "目录ID", required = true),
-            @ApiImplicitParam(name = "name", value = "新目录名", required = true)
-    })
+    @ApiImplicitParams({@ApiImplicitParam(name = "dirId", value = "目录ID", required = true), @ApiImplicitParam(name = "name", value = "新目录名", required = true)})
     public AjaxResult rename(Long dirId, String name) {
         DocDir docDir = new DocDir();
         docDir.setDirId(dirId);

+ 2 - 0
doc-biz/src/main/java/com/doc/biz/controller/DocRecentController.java

@@ -7,6 +7,7 @@ import com.doc.common.core.controller.BaseController;
 import com.doc.common.core.domain.AjaxResult;
 import com.doc.common.core.page.TableDataInfo;
 import com.doc.common.enums.BusinessType;
+import com.doc.common.utils.SecurityUtils;
 import com.doc.common.utils.poi.ExcelUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -37,6 +38,7 @@ public class DocRecentController extends BaseController {
     @GetMapping("/list")
     public TableDataInfo list(DocRecent docRecent) {
         startPage();
+        docRecent.setOwner(SecurityUtils.getUserId());
         List<DocRecent> list = docRecentService.selectDocRecentList(docRecent);
         return getDataTable(list);
     }

+ 6 - 46
doc-biz/src/main/java/com/doc/biz/domain/DocRecent.java

@@ -1,11 +1,11 @@
 package com.doc.biz.domain;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.doc.common.core.domain.BaseEntity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
+import lombok.Data;
 
 /**
  * 最近文件对象 doc_recent
@@ -14,6 +14,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
  * @date 2023-08-21
  */
 @ApiModel(value = "DocRecent", description = "最近文件")
+@Data
 public class DocRecent extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
@@ -42,50 +43,9 @@ public class DocRecent extends BaseEntity {
     @ApiModelProperty("所有人")
     private Long owner;
 
-    public void setRecentId(Long recentId) {
-        this.recentId = recentId;
-    }
+    @ApiModelProperty("文件/文件夹名称")
+    @TableField(exist = false)
+    private String name;
 
-    public Long getRecentId() {
-        return recentId;
-    }
 
-    public void setIsFolder(String isFolder) {
-        this.isFolder = isFolder;
-    }
-
-    public String getIsFolder() {
-        return isFolder;
-    }
-
-    public void setRelaId(Long relaId) {
-        this.relaId = relaId;
-    }
-
-    public Long getRelaId() {
-        return relaId;
-    }
-
-    public void setOwner(Long owner) {
-        this.owner = owner;
-    }
-
-    public Long getOwner() {
-        return owner;
-    }
-
-    @Override
-    public String toString() {
-        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
-                .append("recentId", getRecentId())
-                .append("isFolder", getIsFolder())
-                .append("relaId", getRelaId())
-                .append("owner", getOwner())
-                .append("createBy", getCreateBy())
-                .append("createTime", getCreateTime())
-                .append("updateBy", getUpdateBy())
-                .append("updateTime", getUpdateTime())
-                .append("remark", getRemark())
-                .toString();
-    }
 }

+ 17 - 10
doc-biz/src/main/resources/mapper/biz/DocRecentMapper.xml

@@ -17,22 +17,29 @@
     </resultMap>
 
     <sql id="selectDocRecentVo">
-        select RECENT_ID,
-               IS_FOLDER,
-               RELA_ID,
-               OWNER,
-               CREATE_BY,
-               CREATE_TIME,
-               UPDATE_BY,
-               UPDATE_TIME,
-               REMARK
-        from doc_recent
+        select *
+        from (SELECT A.RECENT_ID,
+                     A.IS_FOLDER,
+                     A.RELA_ID,
+                     A.OWNER,
+                     A.CREATE_BY,
+                     A.CREATE_TIME,
+                     A.UPDATE_BY,
+                     A.UPDATE_TIME,
+                     A.REMARK,
+                     CASE WHEN A.IS_FOLDER = 'Y' THEN B.DIR_NAME ELSE C.FILE_NAME END NAME
+              FROM DOC_RECENT A
+                       LEFT JOIN DOC_DIR B ON A.RELA_ID = B.DIR_ID
+                       LEFT JOIN DOC_INFO C ON A.RELA_ID = C.DOC_ID) t
     </sql>
 
     <select id="selectDocRecentList" parameterType="DocRecent" resultMap="DocRecentResult">
         <include refid="selectDocRecentVo"/>
         <where>
+            <if test="isFolder != null  and isFolder != ''">and IS_FOLDER = #{isFolder}</if>
+            <if test="owner != null  and owner != ''">and OWNER = #{owner}</if>
         </where>
+        order by create_time desc
     </select>
 
     <select id="selectDocRecentByRecentId" parameterType="Long" resultMap="DocRecentResult">