[xingyu.guo] feat: 1. 替换所有响应值中的id为num,不将非业务字段展示给外部 2. 调整[实际使用时间]等字段类型为double,方便计算\保存与读取 3. 【获取所有任务列表】api,完善功能,并增加分页功能 4.将int类型修改为使用Integer,更加安全
This commit is contained in:
+6
-3
@@ -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);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
package com.guo.learningprogresstracker.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.guo.learningprogresstracker.dto.PriorityDto;
|
||||
import com.guo.learningprogresstracker.dto.TaskInfo;
|
||||
import com.guo.learningprogresstracker.dto.request.TaskRequest;
|
||||
import com.guo.learningprogresstracker.dto.response.TaskInfoResponse;
|
||||
import com.guo.learningprogresstracker.dto.response.TasksListInfoResponse;
|
||||
import com.guo.learningprogresstracker.entity.TaskEntity;
|
||||
import com.guo.learningprogresstracker.mapStruct.RequestConvert;
|
||||
import com.guo.learningprogresstracker.mapStruct.TaskConvert;
|
||||
import com.guo.learningprogresstracker.mapStruct.TaskConvertImpl;
|
||||
import com.guo.learningprogresstracker.service.TasksService;
|
||||
import com.guo.learningprogresstracker.mapper.TasksMapper;
|
||||
import com.guo.learningprogresstracker.utils.CalculatedPriorityTool;
|
||||
@@ -17,6 +22,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.rmi.ServerException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author guo
|
||||
@@ -30,12 +36,15 @@ public class TasksServiceImpl extends ServiceImpl<TasksMapper, TaskEntity>
|
||||
implements TasksService{
|
||||
|
||||
|
||||
@Override
|
||||
public TasksListInfoResponse taskList() {
|
||||
private final TasksMapper tasksMapper;
|
||||
private final TaskConvertImpl taskConvertImpl;
|
||||
|
||||
TasksListInfoResponse result = new TasksListInfoResponse();
|
||||
@Override
|
||||
public Page<TaskInfo> taskList(Integer pageNum, Integer pageSize) {
|
||||
Page<TaskEntity> page = tasksMapper.selectPage(new Page<TaskEntity>(pageNum, pageSize), Wrappers.lambdaQuery(TaskEntity.class));
|
||||
//todo 补充返回内容
|
||||
return result;
|
||||
Page<TaskInfo> response = taskConvertImpl.MAPPER.toTaskInfoPage(page);
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user