From a64daacc71f738ce7aaa396a129f652f048877b0 Mon Sep 17 00:00:00 2001 From: cat_shark <1716967236@qq.com> Date: Sat, 30 May 2026 17:36:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=BB=93=E6=9D=9F=E4=BC=9A=E8=AF=9D?= =?UTF-8?q?=E6=97=B6=E8=BF=94=E5=9B=9E=E6=9C=89=E6=95=88=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E4=B8=8D=E8=B6=B3=E7=9A=84=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - StudySessionsServiceImpl: 检测 effectiveTime 被清零时返回提示消息 - StudySessionController: 将提示消息通过 CommonResult.success(message) 传给前端 --- .../controller/StudySessionController.java | 4 ++-- .../service/impl/StudySessionsServiceImpl.java | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/guo/learningprogresstracker/controller/StudySessionController.java b/src/main/java/com/guo/learningprogresstracker/controller/StudySessionController.java index dcaf722..9174800 100644 --- a/src/main/java/com/guo/learningprogresstracker/controller/StudySessionController.java +++ b/src/main/java/com/guo/learningprogresstracker/controller/StudySessionController.java @@ -67,8 +67,8 @@ public class StudySessionController { @PostMapping("/{sessionNum}/study-sessions/ended") public CommonResult endedStudySession(@PathVariable("sessionNum") String sessionNum, @Valid @RequestBody EndedStudySessionRequest request) throws ErrorParameterException { - studySessionsServiceImpl.endedStudySession(sessionNum, request.getContent()); - return CommonResult.success(); + String message = studySessionsServiceImpl.endedStudySession(sessionNum, request.getContent()); + return message != null ? CommonResult.success(message) : CommonResult.success(); } /** diff --git a/src/main/java/com/guo/learningprogresstracker/service/impl/StudySessionsServiceImpl.java b/src/main/java/com/guo/learningprogresstracker/service/impl/StudySessionsServiceImpl.java index 2a7065a..d8d55a1 100644 --- a/src/main/java/com/guo/learningprogresstracker/service/impl/StudySessionsServiceImpl.java +++ b/src/main/java/com/guo/learningprogresstracker/service/impl/StudySessionsServiceImpl.java @@ -93,16 +93,21 @@ public class StudySessionsServiceImpl extends ServiceImpl new ErrorParameterException("会话[" + sessionNum + "]不存在")); + boolean wasOngoing = StudySessionStateEnum.ONGOING.name().equals(studySessionsEntity.getSessionState()); studySessionsEntity.endedStudySession(); this.updateById(studySessionsEntity); StudyReportsEntity studyReportsEntity = new StudyReportsEntity(); studyReportsEntity.setSessionNum(sessionNum); studyReportsEntity.setContent(content); studyReportsMapper.insert(studyReportsEntity); + if (wasOngoing && studySessionsEntity.getEffectiveTime() == 0) { + return "本次有效学习时间不足10分钟,不计入总学习时间"; + } + return null; } @Override