[xingyu.guo] feat: 【结束一个【学习会话】】API
This commit is contained in:
@@ -17,4 +17,8 @@ public interface StudySessionsService extends IService<StudySessionsEntity> {
|
||||
StudySessionResponce getNotEndedStudySessionByTaskNum(String taskNum) throws ErrorParameterException;
|
||||
|
||||
ArrayList<String> getAllFragments(String sessionNum) throws ErrorParameterException;
|
||||
|
||||
void endedStudySession(String sessionNum, String content) throws ErrorParameterException;
|
||||
|
||||
void pauseStudySession(String sessionNum) throws ErrorParameterException;
|
||||
}
|
||||
|
||||
+21
-1
@@ -4,6 +4,7 @@ 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.entity.StudyReportFragmentsEntity;
|
||||
import com.guo.learningprogresstracker.entity.StudyReportsEntity;
|
||||
import com.guo.learningprogresstracker.entity.StudySessionsEntity;
|
||||
import com.guo.learningprogresstracker.entity.TaskEntity;
|
||||
import com.guo.learningprogresstracker.enums.StudySessionStateEnum;
|
||||
@@ -11,6 +12,7 @@ import com.guo.learningprogresstracker.exception.ErrorParameterException;
|
||||
import com.guo.learningprogresstracker.exception.NotFindEntitiesException;
|
||||
import com.guo.learningprogresstracker.mapStruct.StudySessionConvert;
|
||||
import com.guo.learningprogresstracker.mapper.StudyReportFragmentsMapper;
|
||||
import com.guo.learningprogresstracker.mapper.StudyReportsMapper;
|
||||
import com.guo.learningprogresstracker.mapper.StudySessionsMapper;
|
||||
import com.guo.learningprogresstracker.service.StudySessionsService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -29,11 +31,12 @@ import java.util.stream.Collectors;
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class StudySessionsServiceImpl extends ServiceImpl<StudySessionsMapper, StudySessionsEntity>
|
||||
implements StudySessionsService{
|
||||
implements StudySessionsService {
|
||||
|
||||
private final TasksServiceImpl tasksServiceImpl;
|
||||
private final StudyReportFragmentsServiceImpl studyReportFragmentsServiceImpl;
|
||||
private final StudyReportFragmentsMapper studyReportFragmentsMapper;
|
||||
private final StudyReportsMapper studyReportsMapper;
|
||||
|
||||
public StudySessionResponce startOrContinueStudySession(String taskNum) throws NotFindEntitiesException {
|
||||
// taskNum是否存在
|
||||
@@ -60,6 +63,7 @@ public class StudySessionsServiceImpl extends ServiceImpl<StudySessionsMapper, S
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pauseStudySession(String sessionNum) throws ErrorParameterException {
|
||||
StudySessionsEntity studySessionsEntity = this.getOneOpt(Wrappers.lambdaQuery(StudySessionsEntity.class)
|
||||
.eq(StudySessionsEntity::getSessionNum, sessionNum))
|
||||
@@ -68,6 +72,21 @@ public class StudySessionsServiceImpl extends ServiceImpl<StudySessionsMapper, S
|
||||
this.updateById(studySessionsEntity);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void endedStudySession(String sessionNum, String content) throws ErrorParameterException {
|
||||
StudySessionsEntity studySessionsEntity = this.getOneOpt(Wrappers.lambdaQuery(StudySessionsEntity.class)
|
||||
.eq(StudySessionsEntity::getSessionNum, sessionNum))
|
||||
.orElseThrow(() -> new ErrorParameterException("会话[" + sessionNum + "]不存在"));
|
||||
studySessionsEntity.endedStudySession();
|
||||
this.updateById(studySessionsEntity);
|
||||
// 创建学习报告
|
||||
StudyReportsEntity studyReportsEntity = new StudyReportsEntity();
|
||||
studyReportsEntity.setSessionNum(sessionNum);
|
||||
studyReportsEntity.setContent(content);
|
||||
studyReportsMapper.insert(studyReportsEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StudySessionResponce getNotEndedStudySessionByTaskNum(String taskNum) throws ErrorParameterException {
|
||||
StudySessionsEntity studySessionsEntity = this.getOneOpt(Wrappers.lambdaQuery(StudySessionsEntity.class)
|
||||
@@ -89,6 +108,7 @@ public class StudySessionsServiceImpl extends ServiceImpl<StudySessionsMapper, S
|
||||
throw new ErrorParameterException("会话[" + sessionNum + "]不存在");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user