1. 开始或继续一个【学习会话】API 2. 暂停一个【学习会话】API 3.通过sessionId获取一个【学习会话】API
This commit is contained in:
@@ -1,9 +1,54 @@
|
||||
package com.guo.learningprogresstracker.controller;
|
||||
|
||||
import com.guo.learningprogresstracker.dto.response.StudySessionResponce;
|
||||
import com.guo.learningprogresstracker.entity.CommonResult;
|
||||
import com.guo.learningprogresstracker.entity.StudySessionsEntity;
|
||||
import com.guo.learningprogresstracker.exception.ErrorParameterException;
|
||||
import com.guo.learningprogresstracker.mapStruct.StudySessionConvert;
|
||||
import com.guo.learningprogresstracker.service.impl.StudySessionsServiceImpl;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 学习会话控制层
|
||||
*/
|
||||
@RequestMapping("/study-sessions")
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Validated
|
||||
public class StudySessionController {
|
||||
|
||||
private final StudySessionsServiceImpl studySessionsServiceImpl;
|
||||
|
||||
@PostMapping
|
||||
public void studySessionList() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过sessionId获取一个【学习会话】
|
||||
*/
|
||||
@GetMapping("/{sessionId}")
|
||||
public CommonResult getStudySession(@NotEmpty(message = "sessionId不可为空") @PathVariable String sessionId) throws ErrorParameterException {
|
||||
StudySessionsEntity studySessionsEntity = studySessionsServiceImpl.getOptById(sessionId)
|
||||
.orElseThrow(() -> new ErrorParameterException("会话[" + sessionId + "]不存在"));
|
||||
StudySessionResponce studySessionResponce = StudySessionConvert.MAPPER.toStudySessionResponce(studySessionsEntity);
|
||||
return CommonResult.success(studySessionResponce);
|
||||
}
|
||||
|
||||
/**
|
||||
* 暂停一个【学习会话】
|
||||
*/
|
||||
@PostMapping("/{taskId}/studay-sessions/pause")
|
||||
public CommonResult pauseStudySession(@PathVariable("sessionId") String sessionId) throws ErrorParameterException {
|
||||
studySessionsServiceImpl.pauseStudySession(sessionId);
|
||||
return CommonResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user