[xingyu.guo] feat: 1. 替换所有响应值中的id为num,不将非业务字段展示给外部 2. 调整[实际使用时间]等字段类型为double,方便计算\保存与读取 3. 【获取所有任务列表】api,完善功能,并增加分页功能 4.将int类型修改为使用Integer,更加安全
This commit is contained in:
+10
-8
@@ -1,5 +1,6 @@
|
||||
package com.guo.learningprogresstracker.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.guo.learningprogresstracker.dto.response.StudySessionResponce;
|
||||
import com.guo.learningprogresstracker.entity.CommonResult;
|
||||
import com.guo.learningprogresstracker.entity.StudySessionsEntity;
|
||||
@@ -32,12 +33,13 @@ public class StudySessionController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过sessionId获取一个【学习会话】
|
||||
* 通过sessionNum获取一个【学习会话】
|
||||
*/
|
||||
@GetMapping("/{sessionId}")
|
||||
public CommonResult getStudySession(@NotEmpty(message = "sessionId不可为空") @PathVariable String sessionId) throws ErrorParameterException {
|
||||
StudySessionsEntity studySessionsEntity = studySessionsServiceImpl.getOptById(sessionId)
|
||||
.orElseThrow(() -> new ErrorParameterException("会话[" + sessionId + "]不存在"));
|
||||
@GetMapping("/{sessionNum}")
|
||||
public CommonResult getStudySession(@NotEmpty(message = "sessionId不可为空") @PathVariable String sessionNum) throws ErrorParameterException {
|
||||
StudySessionsEntity studySessionsEntity = studySessionsServiceImpl.getOneOpt(Wrappers.lambdaQuery(StudySessionsEntity.class)
|
||||
.eq(StudySessionsEntity::getSessionNum, sessionNum))
|
||||
.orElseThrow(() -> new ErrorParameterException("会话[" + sessionNum + "]不存在"));
|
||||
StudySessionResponce studySessionResponce = StudySessionConvert.MAPPER.toStudySessionResponce(studySessionsEntity);
|
||||
return CommonResult.success(studySessionResponce);
|
||||
}
|
||||
@@ -45,9 +47,9 @@ public class StudySessionController {
|
||||
/**
|
||||
* 暂停一个【学习会话】
|
||||
*/
|
||||
@PostMapping("/{taskId}/studay-sessions/pause")
|
||||
public CommonResult pauseStudySession(@PathVariable("sessionId") String sessionId) throws ErrorParameterException {
|
||||
studySessionsServiceImpl.pauseStudySession(sessionId);
|
||||
@PostMapping("/{sessionNum}/studay-sessions/pause")
|
||||
public CommonResult pauseStudySession(@PathVariable("sessionNum") String sessionNum) throws ErrorParameterException {
|
||||
studySessionsServiceImpl.pauseStudySession(sessionNum);
|
||||
return CommonResult.success();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.rmi.ServerException;
|
||||
@@ -64,8 +65,9 @@ public class TaskController {
|
||||
|
||||
@GetMapping("/tasks")
|
||||
@Operation(summary = "获取所有任务列表")
|
||||
public CommonResult tasksList() {
|
||||
return CommonResult.success(tasksService.taskList());
|
||||
public CommonResult tasksList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
return CommonResult.success(tasksService.taskList(pageNum, pageSize));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +75,7 @@ public class TaskController {
|
||||
*
|
||||
*/
|
||||
@GetMapping("/{taskNum}/studay-sessions/start-or-continue")
|
||||
public CommonResult startOrContinueStudySession(@NotEmpty(message = "taskId不可为空")
|
||||
public CommonResult startOrContinueStudySession(@NotEmpty(message = "taskNum不可为空")
|
||||
@PathVariable String taskNum) throws NotFindEntitiesException {
|
||||
StudySessionResponce responce = studySessionsServiceImpl.startOrContinueStudySession(taskNum);
|
||||
return CommonResult.success(responce);
|
||||
|
||||
Reference in New Issue
Block a user