feat:1. 修正错误命名 2. 为学习会话详情接口增加taskName字段
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package com.guo.learningprogresstracker.service;
|
||||
|
||||
import com.guo.learningprogresstracker.dto.response.StudySessionResponce;
|
||||
import com.guo.learningprogresstracker.dto.response.StudySessionResponse;
|
||||
import com.guo.learningprogresstracker.entity.StudySessionsEntity;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.guo.learningprogresstracker.exception.ErrorParameterException;
|
||||
@@ -14,7 +14,7 @@ import java.util.ArrayList;
|
||||
*/
|
||||
public interface StudySessionsService extends IService<StudySessionsEntity> {
|
||||
|
||||
StudySessionResponce getNotEndedStudySessionByTaskNum(String taskNum) throws ErrorParameterException;
|
||||
StudySessionResponse getNotEndedStudySessionByTaskNum(String taskNum) throws ErrorParameterException;
|
||||
|
||||
ArrayList<String> getAllFragments(String sessionNum) throws ErrorParameterException;
|
||||
|
||||
|
||||
+8
-9
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user