From c696397d83159ced3313661a5235779eedd6acda Mon Sep 17 00:00:00 2001 From: cat_shark <1716967236@qq.com> Date: Sun, 12 Apr 2026 13:06:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=AD=A6=E4=B9=A0=E4=BC=9A?= =?UTF-8?q?=E8=AF=9D=E8=AE=A1=E6=97=B6=E6=8C=87=E9=92=88=E4=B8=8E=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=8D=95=E4=BD=8D=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/StudySessionResponse.java | 6 +++--- .../entity/StudySessionsEntity.java | 19 +++++++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/guo/learningprogresstracker/dto/response/StudySessionResponse.java b/src/main/java/com/guo/learningprogresstracker/dto/response/StudySessionResponse.java index 1041fac..db0a828 100644 --- a/src/main/java/com/guo/learningprogresstracker/dto/response/StudySessionResponse.java +++ b/src/main/java/com/guo/learningprogresstracker/dto/response/StudySessionResponse.java @@ -28,11 +28,11 @@ public class StudySessionResponse { private LocalDateTime endTime; - @Schema(description = "实际使用时间(分钟)") + @Schema(description = "实际使用时间(秒)") private double actualTime; - @Schema(description = "有效学习时间(分钟)") + @Schema(description = "有效学习时间(秒)") private double effectiveTime; @@ -43,7 +43,7 @@ public class StudySessionResponse { @Schema(description = "学习会话的状态(进行中、暂停、已结束)") private String sessionState; - @Schema(description = "倒计时开始位置(S)") + @Schema(description = "倒计时指针位置(毫秒)") private double pointerPosition; @Schema(description = "系统提示") diff --git a/src/main/java/com/guo/learningprogresstracker/entity/StudySessionsEntity.java b/src/main/java/com/guo/learningprogresstracker/entity/StudySessionsEntity.java index 2baa7df..95e9c4a 100644 --- a/src/main/java/com/guo/learningprogresstracker/entity/StudySessionsEntity.java +++ b/src/main/java/com/guo/learningprogresstracker/entity/StudySessionsEntity.java @@ -95,6 +95,8 @@ public class StudySessionsEntity extends BaseEntity implements Serializable { StudySessionsEntity studySessionsEntity = new StudySessionsEntity(); studySessionsEntity.setSessionNum(GenerateNumTool.generateNum("SESSION")); studySessionsEntity.setStartTime(LocalDateTime.now()); + studySessionsEntity.setLastStartTime(LocalDateTime.now()); + studySessionsEntity.setPointerPosition(WORK_DURATION * 60 * 1000L); studySessionsEntity.setLastModifiedTime(LocalDateTime.now()); studySessionsEntity.setSessionState(StudySessionStateEnum.ONGOING.name()); return studySessionsEntity; @@ -150,13 +152,7 @@ public class StudySessionsEntity extends BaseEntity implements Serializable { * @return */ public boolean isFirstRun() { - if (ObjectUtils.isEmpty(this.lastStartTime)) { - return false; - } else if (this.lastStartTime.equals(this.startTime)) { - return true; - } else { - return false; - } + return ObjectUtils.isEmpty(this.pointerPosition); } @@ -187,10 +183,13 @@ public class StudySessionsEntity extends BaseEntity implements Serializable { case ONGOING: long elapsedMillis = Duration.between(lastStartTime, LocalDateTime.now()).toMillis(); - long newPointerPosition = pointerPosition - elapsedMillis; + long basePointerPosition = ObjectUtils.isEmpty(pointerPosition) + ? WORK_DURATION * 60 * 1000L + : pointerPosition; + long newPointerPosition = basePointerPosition - elapsedMillis; if (newPointerPosition <= 0) { // 如果循环已经结束,则需要重置指针位置 - this.pointerPosition = WORK_DURATION * 1000L; + this.pointerPosition = WORK_DURATION * 60 * 1000L; } else { this.pointerPosition = newPointerPosition; } @@ -215,4 +214,4 @@ public class StudySessionsEntity extends BaseEntity implements Serializable { long minutes = Duration.between(ObjectUtils.isEmpty(lastStartTime) ? LocalDateTime.now() : lastStartTime, now).toMinutes(); return minutes >= WORK_DURATION * 2; } -} \ No newline at end of file +}