From 591dc89e53ea9d36093cb652f8064fd40b61c0a1 Mon Sep 17 00:00:00 2001 From: cat_shark <1716967236@qq.com> Date: Sat, 30 May 2026 17:36:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9C=89=E6=95=88=E5=AD=A6=E4=B9=A0?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E4=B8=8D=E8=B6=B310=E5=88=86=E9=92=9F?= =?UTF-8?q?=E4=B8=8D=E8=AE=A1=E5=85=A5=E6=80=BB=E5=AD=A6=E4=B9=A0=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - StudySessionsEntity: 新增 MIN_EFFECTIVE_TIME_SECONDS 常量, endedStudySession() 中检查 effectiveTime,不足则清零 - StudySessionsService: endedStudySession 返回类型从 void 改为 String --- .../entity/StudySessionsEntity.java | 12 +++++++++++- .../service/StudySessionsService.java | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/guo/learningprogresstracker/entity/StudySessionsEntity.java b/src/main/java/com/guo/learningprogresstracker/entity/StudySessionsEntity.java index c68209c..9cfa94f 100644 --- a/src/main/java/com/guo/learningprogresstracker/entity/StudySessionsEntity.java +++ b/src/main/java/com/guo/learningprogresstracker/entity/StudySessionsEntity.java @@ -132,6 +132,11 @@ public class StudySessionsEntity extends BaseEntity implements Serializable { } } + /** + * 有效学习时间的最小阈值(秒),低于此值不计入总学习时间 + */ + private static final double MIN_EFFECTIVE_TIME_SECONDS = 10 * 60; + /** * 结束会话 */ @@ -140,7 +145,12 @@ public class StudySessionsEntity extends BaseEntity implements Serializable { log.warn("不应出现的情况:结束了一个状态为【{}】的学习会话",this.getSessionState()); }else { if (this.getSessionState().equals(StudySessionStateEnum.ONGOING.name())) { - this.pausedStudySession(endTime); + this.pausedStudySession(LocalDateTime.now()); + } + if (this.getEffectiveTime() < MIN_EFFECTIVE_TIME_SECONDS) { + log.info("会话[{}]有效学习时间({}秒)不足10分钟,不计入总学习时间", this.getSessionNum(), this.getEffectiveTime()); + this.setEffectiveTime(0); + this.setEffectivenessRatio(0); } this.setSessionState(StudySessionStateEnum.ENDED.name()); } diff --git a/src/main/java/com/guo/learningprogresstracker/service/StudySessionsService.java b/src/main/java/com/guo/learningprogresstracker/service/StudySessionsService.java index 77a8a4d..43880e6 100644 --- a/src/main/java/com/guo/learningprogresstracker/service/StudySessionsService.java +++ b/src/main/java/com/guo/learningprogresstracker/service/StudySessionsService.java @@ -20,7 +20,7 @@ public interface StudySessionsService extends IService { ArrayList getAllFragments(String sessionNum) throws ErrorParameterException; - void endedStudySession(String sessionNum, String content) throws ErrorParameterException; + String endedStudySession(String sessionNum, String content) throws ErrorParameterException; void pauseStudySession(String sessionNum, LocalDateTime endTime) throws ErrorParameterException, ServiceException;