[xingyu.guo] feat: 1. 抽取通用url 2. 完成【通过学习任务num获取该任务的未结束会话】API 3. 优化【通过sessionNum获取一个【学习会话】】API名称
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package com.guo.learningprogresstracker.service;
|
||||
|
||||
import com.guo.learningprogresstracker.dto.response.StudySessionResponce;
|
||||
import com.guo.learningprogresstracker.entity.StudySessionsEntity;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.guo.learningprogresstracker.exception.ErrorParameterException;
|
||||
|
||||
/**
|
||||
* @author guo
|
||||
@@ -10,4 +12,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
*/
|
||||
public interface StudySessionsService extends IService<StudySessionsEntity> {
|
||||
|
||||
StudySessionResponce getNotEndedStudySessionByTaskNum(String taskNum) throws ErrorParameterException;
|
||||
}
|
||||
|
||||
+9
@@ -61,6 +61,15 @@ public class StudySessionsServiceImpl extends ServiceImpl<StudySessionsMapper, S
|
||||
studySessionsEntity.pausedStudySession();
|
||||
this.updateById(studySessionsEntity);
|
||||
}
|
||||
|
||||
@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()))
|
||||
.orElseThrow(() -> new ErrorParameterException("任务[" + taskNum + "]不存在进行中或暂停中的会话"));
|
||||
return StudySessionConvert.MAPPER.toStudySessionResponce(studySessionsEntity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user