From 3336eeb6aa0049706d5f0c88dfe741b35f68bee2 Mon Sep 17 00:00:00 2001 From: Leo Date: Fri, 16 Jan 2026 18:07:24 +0800 Subject: [PATCH] 1 --- .../com/ruoyi/jarvis/domain/dto/CommentStatistics.java | 4 ++++ .../ruoyi/jarvis/service/impl/CommentServiceImpl.java | 9 +++++++++ .../src/main/resources/mapper/jarvis/CommentMapper.xml | 3 ++- .../main/resources/mapper/jarvis/TaobaoCommentMapper.xml | 3 ++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/jarvis/domain/dto/CommentStatistics.java b/ruoyi-system/src/main/java/com/ruoyi/jarvis/domain/dto/CommentStatistics.java index 79f9992..5c10ea5 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/jarvis/domain/dto/CommentStatistics.java +++ b/ruoyi-system/src/main/java/com/ruoyi/jarvis/domain/dto/CommentStatistics.java @@ -1,6 +1,7 @@ package com.ruoyi.jarvis.domain.dto; import lombok.Data; +import java.util.Date; /** * 评论统计信息 @@ -30,5 +31,8 @@ public class CommentStatistics { /** 今日调用次数 */ private Long todayCallCount; + + /** 最后一条评论的创建时间(作为更新日期) */ + private Date lastCommentUpdateTime; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/impl/CommentServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/impl/CommentServiceImpl.java index 417e3b6..d5cad06 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/impl/CommentServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/impl/CommentServiceImpl.java @@ -134,6 +134,15 @@ public class CommentServiceImpl implements ICommentService { stats.setTotalCount(((Number) statMap.get("totalCount")).longValue()); stats.setAvailableCount(((Number) statMap.get("availableCount")).longValue()); stats.setUsedCount(((Number) statMap.get("usedCount")).longValue()); + // 设置最后一条评论的创建时间 + Object lastUpdateTime = statMap.get("lastCommentUpdateTime"); + if (lastUpdateTime != null) { + if (lastUpdateTime instanceof Date) { + stats.setLastCommentUpdateTime((Date) lastUpdateTime); + } else if (lastUpdateTime instanceof java.sql.Timestamp) { + stats.setLastCommentUpdateTime(new Date(((java.sql.Timestamp) lastUpdateTime).getTime())); + } + } } // 获取接口调用统计 diff --git a/ruoyi-system/src/main/resources/mapper/jarvis/CommentMapper.xml b/ruoyi-system/src/main/resources/mapper/jarvis/CommentMapper.xml index b899f8b..1d414cd 100644 --- a/ruoyi-system/src/main/resources/mapper/jarvis/CommentMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/jarvis/CommentMapper.xml @@ -46,7 +46,8 @@ select count(*) as totalCount, sum(case when is_use = 0 then 1 else 0 end) as availableCount, - sum(case when is_use = 1 then 1 else 0 end) as usedCount + sum(case when is_use = 1 then 1 else 0 end) as usedCount, + (select max(created_at) from comments where product_id = #{productId}) as lastCommentUpdateTime from comments where product_id = #{productId} diff --git a/ruoyi-system/src/main/resources/mapper/jarvis/TaobaoCommentMapper.xml b/ruoyi-system/src/main/resources/mapper/jarvis/TaobaoCommentMapper.xml index f465f6c..8c212c6 100644 --- a/ruoyi-system/src/main/resources/mapper/jarvis/TaobaoCommentMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/jarvis/TaobaoCommentMapper.xml @@ -46,7 +46,8 @@ select count(*) as totalCount, sum(case when is_use = 0 then 1 else 0 end) as availableCount, - sum(case when is_use = 1 then 1 else 0 end) as usedCount + sum(case when is_use = 1 then 1 else 0 end) as usedCount, + (select max(created_at) from taobao_comments where product_id = #{productId}) as lastCommentUpdateTime from taobao_comments where product_id = #{productId}