[xingyu.guo] feat: 1. 替换所有响应值中的id为num,不将非业务字段展示给外部 2. 调整[实际使用时间]等字段类型为double,方便计算\保存与读取 3. 【获取所有任务列表】api,完善功能,并增加分页功能 4.将int类型修改为使用Integer,更加安全

This commit is contained in:
guo
2024-09-22 08:20:48 +08:00
parent 7315f02ce6
commit 6005782b14
12 changed files with 86 additions and 67 deletions
@@ -14,6 +14,7 @@ import com.guo.learningprogresstracker.service.StudySessionsService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.Optional;
/**
@@ -41,6 +42,7 @@ public class StudySessionsServiceImpl extends ServiceImpl<StudySessionsMapper, S
// 返回一个新的会话
StudySessionsEntity studySessionsEntity = StudySessionsEntity.initNewSession();
studySessionsEntity.setTaskNum(taskNum);
studySessionsEntity.setLastStartTime(LocalDateTime.now());
this.save(studySessionsEntity);
return StudySessionConvert.MAPPER.toStudySessionResponce(studySessionsEntity);
}else {
@@ -52,9 +54,10 @@ public class StudySessionsServiceImpl extends ServiceImpl<StudySessionsMapper, S
}
}
public void pauseStudySession(String sessionId) throws ErrorParameterException {
StudySessionsEntity studySessionsEntity = this.getOptById(sessionId)
.orElseThrow(() -> new ErrorParameterException("会话[" + sessionId + "]不存在"));
public void pauseStudySession(String sessionNum) throws ErrorParameterException {
StudySessionsEntity studySessionsEntity = this.getOneOpt(Wrappers.lambdaQuery(StudySessionsEntity.class)
.eq(StudySessionsEntity::getSessionNum, sessionNum))
.orElseThrow(() -> new ErrorParameterException("会话[" + sessionNum + "]不存在"));
studySessionsEntity.pausedStudySession();
this.updateById(studySessionsEntity);
}