瀏覽代碼

完成文件收藏相关接口

wukai 1 年之前
父節點
當前提交
0ebba8bfb6

+ 27 - 2
doc-biz/src/main/java/com/doc/biz/controller/DocFavoriteController.java

@@ -1,15 +1,16 @@
 package com.doc.biz.controller;
 
 import com.doc.biz.domain.DocFavorite;
+import com.doc.biz.service.IDocDirService;
 import com.doc.biz.service.IDocFavoriteService;
+import com.doc.biz.service.IDocInfoService;
 import com.doc.common.annotation.Log;
 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.poi.ExcelUtil;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.*;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
@@ -28,6 +29,10 @@ import java.util.List;
 public class DocFavoriteController extends BaseController {
     @Resource
     private IDocFavoriteService docFavoriteService;
+    @Resource
+    private IDocInfoService docInfoService;
+    @Resource
+    private IDocDirService docDirService;
 
     /**
      * 查询文件收藏列表
@@ -42,6 +47,26 @@ public class DocFavoriteController extends BaseController {
     }
 
     /**
+     * 查询文件收藏列表
+     */
+    @ApiOperation("根据标签ID查询列表")
+    //@PreAuthorize("@ss.hasPermi('biz:favorite:list')")
+    @GetMapping("/listByLabelId")
+    public List<DocFavorite> listByLabelId(@ApiParam(value = "标签ID", required = true) @RequestParam Long labelId) {
+        DocFavorite docFavorite = new DocFavorite();
+        docFavorite.setLabelId(labelId);
+        List<DocFavorite> list = docFavoriteService.selectDocFavoriteList(docFavorite);
+        for (DocFavorite favorite : list) {
+            if ("Y".equals(favorite.getIsFolder())) {
+                favorite.setDocDir(docDirService.selectDocDirByDirId(favorite.getRelaId()));
+            } else {
+                favorite.setDocInfo(docInfoService.selectDocInfoByDocId(favorite.getRelaId()));
+            }
+        }
+        return list;
+    }
+
+    /**
      * 导出文件收藏列表
      */
     @ApiOperation("导出文件收藏列表")

+ 30 - 0
doc-biz/src/main/java/com/doc/biz/controller/DocFavoriteLabelController.java

@@ -7,7 +7,9 @@ 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 com.github.pagehelper.PageHelper;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.web.bind.annotation.*;
@@ -76,6 +78,34 @@ public class DocFavoriteLabelController extends BaseController {
     }
 
     /**
+     * 标签排序
+     */
+    @ApiOperation("标签排序")
+    @Log(title = "标签排序", businessType = BusinessType.UPDATE)
+    @PostMapping(value = "order")
+    public AjaxResult order(@RequestBody List<DocFavoriteLabel> labelList) {
+        for (DocFavoriteLabel label : labelList) {
+            label.setLabelName(null);
+            docFavoriteLabelService.updateDocFavoriteLabel(label);
+        }
+        return success();
+    }
+
+    /**
+     * 标签排序
+     */
+    @ApiOperation("标签列表")
+    @Log(title = "标签列表", businessType = BusinessType.UPDATE)
+    @GetMapping(value = "label-list")
+    public List<DocFavoriteLabel> labelList() {
+        PageHelper.startPage(1, 100, "order by order_num").setReasonable(true);
+        DocFavoriteLabel docFavoriteLabel = new DocFavoriteLabel();
+        docFavoriteLabel.setOwner(SecurityUtils.getUserId());
+        List<DocFavoriteLabel> list = docFavoriteLabelService.selectDocFavoriteLabelList(docFavoriteLabel);
+        return list;
+    }
+
+    /**
      * 修改文件收藏标签
      */
     @ApiOperation("修改文件收藏标签")

+ 33 - 13
doc-biz/src/main/java/com/doc/biz/domain/DocFavorite.java

@@ -1,5 +1,6 @@
 package com.doc.biz.domain;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -8,13 +9,15 @@ import org.apache.commons.lang3.builder.ToStringStyle;
 import com.doc.common.annotation.Excel;
 import com.doc.common.core.domain.BaseEntity;
 
+import java.util.List;
+
 /**
  * 文件收藏对象 doc_favorite
  *
  * @author wukai
  * @date 2023-08-21
  */
-@ApiModel(value = "DocFavorite" , description = "文件收藏")
+@ApiModel(value = "DocFavorite", description = "文件收藏")
 public class DocFavorite extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
@@ -49,6 +52,34 @@ public class DocFavorite extends BaseEntity {
      */
     @ApiModelProperty("所有人")
     private Long owner;
+    /**
+     * 所有人
+     */
+    @ApiModelProperty("文件信息")
+    @TableField(exist = false)
+    private DocInfo docInfo;
+    /**
+     * 所有人
+     */
+    @ApiModelProperty("文件夹信息")
+    @TableField(exist = false)
+    private DocDir docDir;
+
+    public DocInfo getDocInfo() {
+        return docInfo;
+    }
+
+    public void setDocInfo(DocInfo docInfo) {
+        this.docInfo = docInfo;
+    }
+
+    public DocDir getDocDir() {
+        return docDir;
+    }
+
+    public void setDocDir(DocDir docDir) {
+        this.docDir = docDir;
+    }
 
     public void setFavoriteId(Long favoriteId) {
         this.favoriteId = favoriteId;
@@ -92,17 +123,6 @@ public class DocFavorite extends BaseEntity {
 
     @Override
     public String toString() {
-        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
-                .append("favoriteId" , getFavoriteId())
-                .append("labelId" , getLabelId())
-                .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();
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("favoriteId", getFavoriteId()).append("labelId", getLabelId()).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();
     }
 }

+ 28 - 10
doc-biz/src/main/java/com/doc/biz/domain/DocFavoriteLabel.java

@@ -12,9 +12,9 @@ import com.doc.common.core.domain.BaseEntity;
  * 文件收藏标签对象 doc_favorite_label
  *
  * @author wukai
- * @date 2023-08-21
+ * @date 2023-08-28
  */
-@ApiModel(value = "DocFavoriteLabel" , description = "文件收藏标签")
+@ApiModel(value = "DocFavoriteLabel", description = "文件收藏标签")
 public class DocFavoriteLabel extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
@@ -29,14 +29,23 @@ public class DocFavoriteLabel extends BaseEntity {
      * 标签名
      */
     @ApiModelProperty("标签名")
+    @Excel(name = "标签名")
     private String labelName;
 
     /**
      * 所有人
      */
     @ApiModelProperty("所有人")
+    @Excel(name = "所有人")
     private Long owner;
 
+    /**
+     * 显示顺序
+     */
+    @ApiModelProperty("显示顺序")
+    @Excel(name = "显示顺序")
+    private Long orderNum;
+
     public void setLabelId(Long labelId) {
         this.labelId = labelId;
     }
@@ -61,17 +70,26 @@ public class DocFavoriteLabel extends BaseEntity {
         return owner;
     }
 
+    public void setOrderNum(Long orderNum) {
+        this.orderNum = orderNum;
+    }
+
+    public Long getOrderNum() {
+        return orderNum;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
-                .append("labelId" , getLabelId())
-                .append("labelName" , getLabelName())
-                .append("owner" , getOwner())
-                .append("createBy" , getCreateBy())
-                .append("createTime" , getCreateTime())
-                .append("updateBy" , getUpdateBy())
-                .append("updateTime" , getUpdateTime())
-                .append("remark" , getRemark())
+                .append("labelId", getLabelId())
+                .append("labelName", getLabelName())
+                .append("owner", getOwner())
+                .append("orderNum", getOrderNum())
+                .append("createBy", getCreateBy())
+                .append("createTime", getCreateTime())
+                .append("updateBy", getUpdateBy())
+                .append("updateTime", getUpdateTime())
+                .append("remark", getRemark())
                 .toString();
     }
 }

+ 42 - 19
doc-biz/src/main/resources/mapper/biz/DocFavoriteLabelMapper.xml

@@ -1,55 +1,75 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.doc.biz.mapper.DocFavoriteLabelMapper">
-    
+
     <resultMap type="DocFavoriteLabel" id="DocFavoriteLabelResult">
-        <result property="labelId"    column="LABEL_ID"    />
-        <result property="labelName"    column="LABEL_NAME"    />
-        <result property="owner"    column="OWNER"    />
-        <result property="createBy"    column="CREATE_BY"    />
-        <result property="createTime"    column="CREATE_TIME"    />
-        <result property="updateBy"    column="UPDATE_BY"    />
-        <result property="updateTime"    column="UPDATE_TIME"    />
-        <result property="remark"    column="REMARK"    />
+        <result property="labelId" column="LABEL_ID"/>
+        <result property="labelName" column="LABEL_NAME"/>
+        <result property="owner" column="OWNER"/>
+        <result property="orderNum" column="ORDER_NUM"/>
+        <result property="createBy" column="CREATE_BY"/>
+        <result property="createTime" column="CREATE_TIME"/>
+        <result property="updateBy" column="UPDATE_BY"/>
+        <result property="updateTime" column="UPDATE_TIME"/>
+        <result property="remark" column="REMARK"/>
     </resultMap>
 
     <sql id="selectDocFavoriteLabelVo">
-        select LABEL_ID, LABEL_NAME, OWNER, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, REMARK from doc_favorite_label
+        select LABEL_ID,
+               LABEL_NAME,
+               OWNER,
+               ORDER_NUM,
+               CREATE_BY,
+               CREATE_TIME,
+               UPDATE_BY,
+               UPDATE_TIME,
+               REMARK
+        from doc_favorite_label
     </sql>
 
     <select id="selectDocFavoriteLabelList" parameterType="DocFavoriteLabel" resultMap="DocFavoriteLabelResult">
         <include refid="selectDocFavoriteLabelVo"/>
-        <where>  
+        <where>
+            <if test="labelName != null  and labelName != ''">and LABEL_NAME like concat('%', #{labelName}, '%')</if>
+            <if test="owner != null ">and OWNER = #{owner}</if>
+            <if test="orderNum != null ">and ORDER_NUM = #{orderNum}</if>
+            <if test="createBy != null  and createBy != ''">and CREATE_BY = #{createBy}</if>
+            <if test="createTime != null ">and CREATE_TIME = #{createTime}</if>
+            <if test="updateBy != null  and updateBy != ''">and UPDATE_BY = #{updateBy}</if>
+            <if test="updateTime != null ">and UPDATE_TIME = #{updateTime}</if>
+            <if test="remark != null  and remark != ''">and REMARK = #{remark}</if>
         </where>
     </select>
-    
+
     <select id="selectDocFavoriteLabelByLabelId" parameterType="Long" resultMap="DocFavoriteLabelResult">
         <include refid="selectDocFavoriteLabelVo"/>
         where LABEL_ID = #{labelId}
     </select>
-        
+
     <insert id="insertDocFavoriteLabel" parameterType="DocFavoriteLabel" useGeneratedKeys="true" keyProperty="labelId">
         insert into doc_favorite_label
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="labelName != null">LABEL_NAME,</if>
             <if test="owner != null">OWNER,</if>
+            <if test="orderNum != null">ORDER_NUM,</if>
             <if test="createBy != null">CREATE_BY,</if>
             <if test="createTime != null">CREATE_TIME,</if>
             <if test="updateBy != null">UPDATE_BY,</if>
             <if test="updateTime != null">UPDATE_TIME,</if>
             <if test="remark != null">REMARK,</if>
-         </trim>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="labelName != null">#{labelName},</if>
             <if test="owner != null">#{owner},</if>
+            <if test="orderNum != null">#{orderNum},</if>
             <if test="createBy != null">#{createBy},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateTime != null">#{updateTime},</if>
             <if test="remark != null">#{remark},</if>
-         </trim>
+        </trim>
     </insert>
 
     <update id="updateDocFavoriteLabel" parameterType="DocFavoriteLabel">
@@ -57,6 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <trim prefix="SET" suffixOverrides=",">
             <if test="labelName != null">LABEL_NAME = #{labelName},</if>
             <if test="owner != null">OWNER = #{owner},</if>
+            <if test="orderNum != null">ORDER_NUM = #{orderNum},</if>
             <if test="createBy != null">CREATE_BY = #{createBy},</if>
             <if test="createTime != null">CREATE_TIME = #{createTime},</if>
             <if test="updateBy != null">UPDATE_BY = #{updateBy},</if>
@@ -67,11 +88,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </update>
 
     <delete id="deleteDocFavoriteLabelByLabelId" parameterType="Long">
-        delete from doc_favorite_label where LABEL_ID = #{labelId}
+        delete
+        from doc_favorite_label
+        where LABEL_ID = #{labelId}
     </delete>
 
     <delete id="deleteDocFavoriteLabelByLabelIds" parameterType="String">
-        delete from doc_favorite_label where LABEL_ID in 
+        delete from doc_favorite_label where LABEL_ID in
         <foreach item="labelId" collection="array" open="(" separator="," close=")">
             #{labelId}
         </foreach>

+ 5 - 5
doc-biz/src/main/resources/mapper/biz/DocFavoriteMapper.xml

@@ -3,7 +3,7 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.doc.biz.mapper.DocFavoriteMapper">
-    
+
     <resultMap type="DocFavorite" id="DocFavoriteResult">
         <result property="favoriteId"    column="FAVORITE_ID"    />
         <result property="labelId"    column="LABEL_ID"    />
@@ -23,16 +23,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectDocFavoriteList" parameterType="DocFavorite" resultMap="DocFavoriteResult">
         <include refid="selectDocFavoriteVo"/>
-        <where>  
+        <where>
             <if test="isFolder != null  and isFolder != ''"> and IS_FOLDER = #{isFolder}</if>
         </where>
     </select>
-    
+
     <select id="selectDocFavoriteByFavoriteId" parameterType="Long" resultMap="DocFavoriteResult">
         <include refid="selectDocFavoriteVo"/>
         where FAVORITE_ID = #{favoriteId}
     </select>
-        
+
     <insert id="insertDocFavorite" parameterType="DocFavorite" useGeneratedKeys="true" keyProperty="favoriteId">
         insert into doc_favorite
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -80,7 +80,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <delete id="deleteDocFavoriteByFavoriteIds" parameterType="String">
-        delete from doc_favorite where FAVORITE_ID in 
+        delete from doc_favorite where FAVORITE_ID in
         <foreach item="favoriteId" collection="array" open="(" separator="," close=")">
             #{favoriteId}
         </foreach>