作者 dong

首頁修改

... ... @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.lettuce.core.dynamic.annotation.Param;
import org.jeecg.modules.airag.app.entity.AiragLog;
import java.util.Date;
import java.util.List;
import java.util.Map;
... ... @@ -33,4 +34,6 @@ public interface AiragLogMapper extends BaseMapper<AiragLog> {
List<Map<String, Object>> getDailyCountForLast7Days();
List<Map<String, Object>> getDailyRejectedCountForLast7Days();
Date getEarliestTime();
}
... ...
... ... @@ -152,4 +152,9 @@
) log_counts ON date_range.date = log_counts.date
ORDER BY date_range.date ASC
</select>
<select id="getEarliestTime" resultType="java.util.Date">
SELECT MIN(create_time) AS earliest_time
FROM airag_log
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -22,10 +22,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* @Description: 日志管理
... ... @@ -96,6 +94,10 @@ public class AiragLogServiceImpl extends ServiceImpl<AiragLogMapper, AiragLog> i
todayWrapper.apply("DATE(create_time) = CURDATE()");
long todayCount = this.count(todayWrapper);
Date earlisetTime = airagLogMapper.getEarliestTime();
SimpleDateFormat sft = new SimpleDateFormat("yyyy年MM月dd日");
String earliestTime = sft.format(earlisetTime);
// 2. 获取昨日问答次数
QueryWrapper<AiragLog> yesterdayWrapper = new QueryWrapper<>();
yesterdayWrapper.apply("DATE(create_time) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)");
... ... @@ -143,6 +145,7 @@ public class AiragLogServiceImpl extends ServiceImpl<AiragLogMapper, AiragLog> i
result.put("yesterdayCount", yesterdayCount);
result.put("growthRate", Math.round(growthRate * 100.0) / 100.0); // 保留两位小数
result.put("todayCount", todayCount);
result.put("earliestTime", earliestTime);
result.put("rejectedCount", rejectedCount);
result.put("totalCount", totalCount);
result.put("averageCount", averageCount);
... ...