feat: 任务开始页面,相关逻辑补充
This commit is contained in:
+23
-3
@@ -58,7 +58,8 @@ public class StudySessionsServiceImpl extends ServiceImpl<StudySessionsMapper, S
|
||||
} else {
|
||||
// 返回已经存在的会话
|
||||
studySessionsEntity = oneOpt.get();
|
||||
studySessionsEntity.continueStudySession();
|
||||
// todo 是否调整任务状态,需要再思考思考
|
||||
// studySessionsEntity.continueStudySession();
|
||||
this.updateById(studySessionsEntity);
|
||||
}
|
||||
StudySessionResponse response = StudySessionConvert.MAPPER.toStudySessionResponse(studySessionsEntity);
|
||||
@@ -67,11 +68,15 @@ public class StudySessionsServiceImpl extends ServiceImpl<StudySessionsMapper, S
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pauseStudySession(String sessionNum) throws ErrorParameterException {
|
||||
public void pauseStudySession(String sessionNum, LocalDateTime endTime) throws ErrorParameterException {
|
||||
StudySessionsEntity studySessionsEntity = this.getOneOpt(Wrappers.lambdaQuery(StudySessionsEntity.class)
|
||||
.eq(StudySessionsEntity::getSessionNum, sessionNum))
|
||||
.orElseThrow(() -> new ErrorParameterException("会话[" + sessionNum + "]不存在"));
|
||||
studySessionsEntity.pausedStudySession();
|
||||
if (StudySessionStateEnum.PAUSED.name().equals(studySessionsEntity.getSessionState())) {
|
||||
log.error("会话[" + studySessionsEntity.getSessionNum() + "]重复暂停");
|
||||
throw new ErrorParameterException("会话[" + sessionNum + "]已经暂停,请勿重复暂停!");
|
||||
}
|
||||
studySessionsEntity.pausedStudySession(endTime);
|
||||
this.updateById(studySessionsEntity);
|
||||
}
|
||||
|
||||
@@ -110,6 +115,21 @@ public class StudySessionsServiceImpl extends ServiceImpl<StudySessionsMapper, S
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void continueStudySession(String sessionNum) throws ErrorParameterException {
|
||||
StudySessionsEntity studySessionsEntity = this.getOneOpt(Wrappers.lambdaQuery(StudySessionsEntity.class)
|
||||
.eq(StudySessionsEntity::getSessionNum, sessionNum))
|
||||
.orElseThrow(() -> new ErrorParameterException("会话[" + sessionNum + "]不存在"));
|
||||
if (StudySessionStateEnum.ONGOING.name().equals(studySessionsEntity.getSessionState())) {
|
||||
log.error("会话[" + studySessionsEntity.getSessionNum() + "]重复开始");
|
||||
throw new ErrorParameterException("会话[" + sessionNum + "]已经开始,请勿重复开始!");
|
||||
} else if (StudySessionStateEnum.ENDED.name().equals(studySessionsEntity.getSessionState())) {
|
||||
log.error("会话[" + studySessionsEntity.getSessionNum() + "]处于结束状态,不可开始该会话!");
|
||||
throw new ErrorParameterException("会话[" + sessionNum + "]处于结束状态,不可开始该会话!");
|
||||
}
|
||||
studySessionsEntity.continueStudySession();
|
||||
this.updateById(studySessionsEntity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user