[xingyu.guo] feat: 【结束一个【学习会话】】API

This commit is contained in:
guo
2024-09-22 15:52:08 +08:00
parent 54af814b5e
commit cecfa7a800
6 changed files with 71 additions and 8 deletions
@@ -1,18 +1,21 @@
package com.guo.learningprogresstracker.controller;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.guo.learningprogresstracker.dto.request.EndedStudySessionRequest;
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.Valid;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -49,12 +52,21 @@ public class StudySessionController {
/**
* 暂停一个【学习会话】
*/
@PostMapping("/{sessionNum}/studay-sessions/pause")
@PostMapping("/{sessionNum}/study-sessions/pause")
public CommonResult pauseStudySession(@PathVariable("sessionNum") String sessionNum) throws ErrorParameterException {
studySessionsServiceImpl.pauseStudySession(sessionNum);
return CommonResult.success();
}
/**
* 结束一个【学习会话】
*/
@PostMapping("/{sessionNum}/study-sessions/ended")
public CommonResult endedStudySession(@PathVariable("sessionNum") String sessionNum,
@Valid @RequestBody EndedStudySessionRequest request) throws ErrorParameterException {
studySessionsServiceImpl.endedStudySession(sessionNum,request.getContent());
return CommonResult.success();
}
/**
* 获取【学习会话】所有的学习残片数据,以列表返回
*/