feat:1. 修正错误命名 2. 为学习会话详情接口增加taskName字段

This commit is contained in:
2025-06-29 16:48:31 +08:00
parent aa9a278108
commit 5f9e01cf14
10 changed files with 106 additions and 36 deletions
@@ -2,7 +2,8 @@ package com.guo.learningprogresstracker.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.guo.learningprogresstracker.dto.response.StudySessionResponce;
import com.guo.learningprogresstracker.dto.StudySessionsDto;
import com.guo.learningprogresstracker.dto.response.StudySessionResponse;
import com.guo.learningprogresstracker.entity.StudyReportFragmentsEntity;
import com.guo.learningprogresstracker.entity.StudyReportsEntity;
import com.guo.learningprogresstracker.entity.StudySessionsEntity;
@@ -38,7 +39,7 @@ public class StudySessionsServiceImpl extends ServiceImpl<StudySessionsMapper, S
private final StudyReportFragmentsMapper studyReportFragmentsMapper;
private final StudyReportsMapper studyReportsMapper;
public StudySessionResponce startOrContinueStudySession(String taskNum) throws NotFindEntitiesException {
public StudySessionResponse startOrContinueStudySession(String taskNum) throws NotFindEntitiesException {
// taskNum是否存在
tasksServiceImpl.getOneOpt(Wrappers.lambdaQuery(TaskEntity.class).eq(TaskEntity::getTaskNum, taskNum))
.orElseThrow(() -> new NotFindEntitiesException(String.format("[%s]不存在",taskNum)));
@@ -53,13 +54,13 @@ public class StudySessionsServiceImpl extends ServiceImpl<StudySessionsMapper, S
studySessionsEntity.setTaskNum(taskNum);
studySessionsEntity.setLastStartTime(LocalDateTime.now());
this.save(studySessionsEntity);
return StudySessionConvert.MAPPER.toStudySessionResponce(studySessionsEntity);
return StudySessionConvert.MAPPER.toStudySessionResponse(studySessionsEntity);
}else {
// 返回已经存在的会话
StudySessionsEntity studySessionsEntity = oneOpt.get();
studySessionsEntity.continueStudySession();
this.updateById(studySessionsEntity);
return StudySessionConvert.MAPPER.toStudySessionResponce(studySessionsEntity);
return StudySessionConvert.MAPPER.toStudySessionResponse(studySessionsEntity);
}
}
@@ -88,12 +89,10 @@ public class StudySessionsServiceImpl extends ServiceImpl<StudySessionsMapper, S
}
@Override
public StudySessionResponce getNotEndedStudySessionByTaskNum(String taskNum) throws ErrorParameterException {
StudySessionsEntity studySessionsEntity = this.getOneOpt(Wrappers.lambdaQuery(StudySessionsEntity.class)
.eq(StudySessionsEntity::getTaskNum, taskNum)
.ne(StudySessionsEntity::getSessionState, StudySessionStateEnum.ENDED.name()))
public StudySessionResponse getNotEndedStudySessionByTaskNum(String taskNum) throws ErrorParameterException {
StudySessionsDto dto = Optional.ofNullable(studyReportsMapper.getNotEndedStudySessionDtoByTaskNum(taskNum))
.orElseThrow(() -> new ErrorParameterException("任务[" + taskNum + "]不存在进行中或暂停中的会话"));
return StudySessionConvert.MAPPER.toStudySessionResponce(studySessionsEntity);
return StudySessionConvert.MAPPER.toStudySessionResponse(dto);
}
@Override