Преглед на файлове

知识库导出积分列表功能调整

徐滕 преди 3 седмици
родител
ревизия
110a882621

+ 6 - 0
src/main/java/com/jeeplus/modules/WorkKnowledgeBase/dao/WorkKnowledgeBaseShareInfoDao.java

@@ -35,4 +35,10 @@ public interface WorkKnowledgeBaseShareInfoDao extends CrudDao<WorkKnowledgeBase
      * 只更新审核状态及审核统计字段
      */
     int updateAuditStatus(WorkKnowledgeBaseShareInfo entity);
+
+    /**
+     * 点击量+1
+     * @param id 文件ID
+     */
+    void incrementClickCount(@org.apache.ibatis.annotations.Param("id") String id);
 }

+ 11 - 0
src/main/java/com/jeeplus/modules/WorkKnowledgeBase/entity/WorkKnowledgeBaseShareInfo.java

@@ -68,6 +68,9 @@ public class WorkKnowledgeBaseShareInfo extends DataEntity<WorkKnowledgeBaseShar
     /** 问题说明(问答答疑专用,富文本) */
     private String questionDescription;
 
+    /** 点击量(每次点击+1,不去重) */
+    private Integer clickCount;
+
     public String getTreeNodeId() {
         return treeNodeId;
     }
@@ -251,4 +254,12 @@ public class WorkKnowledgeBaseShareInfo extends DataEntity<WorkKnowledgeBaseShar
     public void setHome(String home) {
         this.home = home;
     }
+
+    public Integer getClickCount() {
+        return clickCount;
+    }
+
+    public void setClickCount(Integer clickCount) {
+        this.clickCount = clickCount;
+    }
 }

+ 9 - 0
src/main/java/com/jeeplus/modules/WorkKnowledgeBase/service/WorkKnowledgeBaseShareService.java

@@ -1599,4 +1599,13 @@ public class WorkKnowledgeBaseShareService extends CrudService<WorkKnowledgeBase
         }
         return question;
     }
+
+    /**
+     * 点击量+1(每次点击都记录,不去重,不受审核状态限制)
+     * @param id 文件ID
+     */
+    @Transactional(readOnly = false)
+    public void incrementClickCount(String id) {
+        dao.incrementClickCount(id);
+    }
 }

+ 48 - 0
src/main/java/com/jeeplus/modules/WorkKnowledgeBase/web/WorkKnowledgeBaseReadLikeController.java

@@ -5,6 +5,7 @@ import com.jeeplus.common.web.BaseController;
 import com.jeeplus.modules.WorkKnowledgeBase.entity.WorkKnowledgeBaseLikeRecord;
 import com.jeeplus.modules.WorkKnowledgeBase.entity.WorkKnowledgeBaseReadRecord;
 import com.jeeplus.modules.WorkKnowledgeBase.service.WorkKnowledgeBaseReadLikeService;
+import com.jeeplus.modules.WorkKnowledgeBase.service.WorkKnowledgeBaseShareService;
 import com.jeeplus.modules.sys.utils.UserUtils;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -28,6 +29,9 @@ public class WorkKnowledgeBaseReadLikeController extends BaseController {
     @Autowired
     private WorkKnowledgeBaseReadLikeService readLikeService;
 
+    @Autowired
+    private WorkKnowledgeBaseShareService shareService;
+
     /**
      * 记录阅读行为(用户查看详情时调用)
      */
@@ -210,4 +214,48 @@ public class WorkKnowledgeBaseReadLikeController extends BaseController {
         
         return "modules/WorkKnowledgeBase/workKnowledgeBaseLikeDetail";
     }
+
+    /**
+     * 点击量+1(任何状态都记录)
+     */
+    @RequestMapping(value = "incrementClick")
+    @ResponseBody
+    public Map<String, Object> incrementClick(@RequestParam String fileId) {
+        Map<String, Object> result = new HashMap<>();
+        try {
+            shareService.incrementClickCount(fileId);
+            result.put("success", true);
+        } catch (Exception e) {
+            result.put("success", false);
+            result.put("message", "记录点击量失败:" + e.getMessage());
+        }
+        return result;
+    }
+
+    /**
+     * 点击详情页面(展示的阅读详情数据与阅读量详情一致)
+     */
+    @RequestMapping(value = "clickDetailPage")
+    public String clickDetailPage(@RequestParam String fileId,
+                                   @RequestParam(required=false) Integer pageNo,
+                                   @RequestParam(required=false) Integer pageSize,
+                                   Model model) {
+        model.addAttribute("fileId", fileId);
+        
+        Page<WorkKnowledgeBaseReadRecord> page = new Page<>();
+        if (pageNo != null && pageNo > 0) {
+            page.setPageNo(pageNo);
+        }
+        if (pageSize != null && pageSize > 0) {
+            page.setPageSize(pageSize);
+        } else {
+            page.setPageSize(10);
+        }
+        
+        Page<WorkKnowledgeBaseReadRecord> detailPage = readLikeService.findReadDetailPage(page, fileId);
+        model.addAttribute("page", detailPage);
+        model.addAttribute("totalCount", readLikeService.getReadCount(fileId));
+        
+        return "modules/WorkKnowledgeBase/workKnowledgeBaseReadDetail";
+    }
 }

+ 10 - 1
src/main/resources/mappings/modules/WorkKnowledgeBase/WorkKnowledgeBaseShareInfoDao.xml

@@ -23,6 +23,7 @@
         a.answer_id        AS "answerId",
         a.confirm_date     AS "confirmDate",
         a.question_description AS "questionDescription",
+        a.click_count        AS "clickCount",
         a.del_flag         AS "delFlag"
     </sql>
 
@@ -87,6 +88,7 @@
             a.answer_id                                           AS "answerId",
             a.confirm_date                                        AS "confirmDate",
             a.question_description                                AS "questionDescription",
+            a.click_count                                          AS "clickCount",
             su.name                                               AS "createBy.name"
             <!-- 动态列:CASE WHEN + MAX + GROUP BY -->
             <if test="dynamicFields != null and dynamicFields.size() > 0">
@@ -153,7 +155,7 @@
         </where>
         GROUP BY a.id, a.tree_node_id, a.file_name, a.file_url, a.name, a.create_time,
                  a.create_by, a.create_date, a.remarks, a.audit_status, a.audit_pass_count, a.audit_reject_count, a.submit_audit_user_id, a.audit_start_date,
-                 a.content_attribute, a.answer_id, a.confirm_date, a.question_description
+                 a.content_attribute, a.answer_id, a.confirm_date, a.question_description, a.click_count
         ORDER BY a.update_date DESC
         <if test="offset != null and limit != null">
             LIMIT #{offset}, #{limit}
@@ -303,4 +305,11 @@
         WHERE id = #{id}
     </update>
 
+    <!-- 点击量+1 -->
+    <update id="incrementClickCount">
+        UPDATE work_knowledge_base_share_info
+        SET click_count = COALESCE(click_count, 0) + 1
+        WHERE id = #{id} AND del_flag = '0'
+    </update>
+
 </mapper>

+ 26 - 10
src/main/webapp/webpage/modules/WorkKnowledgeBase/workKnowledgeBaseShareList.jsp

@@ -107,17 +107,23 @@
             });
         }
         
-        /** 查看详情(带阅读记录) */
+        /** 查看详情(带阅读记录 + 点击量递增) */
         function openDetailDialogWithRead(id) {
-            // 记录阅读行为
+            // 记录阅读行为 + 递增点击量
             $.ajax({
                 type: 'POST',
                 url: '${ctx}/workKnowledgeBase/readLike/recordRead',
                 data: { fileId: id },
                 success: function(result) {
+                    // 递增点击量(与阅读记录并行,不影响主流程)
+                    $.ajax({
+                        type: 'POST',
+                        url: '${ctx}/workKnowledgeBase/readLike/incrementClick',
+                        data: { fileId: id }
+                    });
                     // 无论是否首次阅读,都打开详情弹窗
                     openDetailDialog(id);
-                    // 刷新列表,更新阅读量
+                    // 刷新列表,更新阅读量和点击量
                     setTimeout(function() {
                         search();
                     }, 500);
@@ -187,17 +193,23 @@
             });
         }
         
-        /** 预览文件(带阅读记录) */
+        /** 预览文件(带阅读记录 + 点击量递增) */
         function openPreviewWithRead(url, type, fileId) {
-            // 记录阅读行为
+            // 记录阅读行为 + 递增点击量
             $.ajax({
                 type: 'POST',
                 url: '${ctx}/workKnowledgeBase/readLike/recordRead',
                 data: { fileId: fileId },
                 success: function(result) {
+                    // 递增点击量(与阅读记录并行,不影响主流程)
+                    $.ajax({
+                        type: 'POST',
+                        url: '${ctx}/workKnowledgeBase/readLike/incrementClick',
+                        data: { fileId: fileId }
+                    });
                     // 调用原有的预览方法
                     openPreview(url, type);
-                    // 刷新列表,更新阅读量
+                    // 刷新列表,更新阅读量和点击量
                     setTimeout(function() {
                         search();
                     }, 500);
@@ -668,13 +680,13 @@
                             <shiro:hasPermission name="workKnowledgeBase:share:export">
                                 <button class="layui-btn layui-btn-sm layui-bg-yellow"
                                         onclick="exportAllTabs()">
-                                    <i class="glyphicon glyphicon-export"></i> 导出
+                                     导出详细列表
                                 </button>
                             </shiro:hasPermission>
                             <shiro:hasPermission name="workKnowledgeBase:point:listAll">
-                                <button class="layui-btn layui-btn-sm layui-bg-cyan"
+                                <button class="layui-btn layui-btn-sm layui-bg-orange"
                                         onclick="exportPointStats()">
-                                    <i class="glyphicon glyphicon-export"></i> 积分统计导出
+                                     导出积分统计
                                 </button>
                             </shiro:hasPermission>
                         </c:if>
@@ -754,7 +766,10 @@
                 }},
             {field: 'createByName', align: 'center', title: '创建人', width: 100},
             {field: 'createTime', align: 'center', title: '创建时间', width: 160},
-            //添加点击量,点击后展示的数据和原先阅读量展示的详情一致,此处点击量即点击查看一下,就记录一下
+            // 点击量(仅展示,通过点击文件名称/文件地址触发递增)
+            {field: 'clickCount', align: 'center', title: '点击量', width: 100, templet: function(d){
+                return '<span style="color:#009688;">' + (d.clickCount || 0) + '</span>';
+            }},
             {field: 'readCount', align: 'center', title: '阅读量', width: 100, templet: function(d){
                 return '<a href="javascript:void(0)" onclick="showReadDetail(\'' + d.id + '\')" style="color:#1e9fff;cursor:pointer;">' + (d.readCount || 0) + '</a>';
             }},
@@ -896,6 +911,7 @@
                     ,"treeNodeId": "${row.treeNodeId}"
                     ,"treeName": "<c:out value='${row.treeName}'/>"
                     ,"isQaCategory": ${row.isQaCategory == true ? 'true' : 'false'}
+                    ,"clickCount": ${row.clickCount != null ? row.clickCount : 0}
                     ,"readCount": ${row.readCount != null ? row.readCount : 0}
                     ,"likeCount": ${row.likeCount != null ? row.likeCount : 0}
                     ,"liked": ${row.liked == true ? 'true' : 'false'}