diff --git a/src/main/java/com/guo/learningprogresstracker/controller/reportFragmentsController.java b/src/main/java/com/guo/learningprogresstracker/controller/reportFragmentsController.java index 7a0f0e7..c39c95e 100644 --- a/src/main/java/com/guo/learningprogresstracker/controller/reportFragmentsController.java +++ b/src/main/java/com/guo/learningprogresstracker/controller/reportFragmentsController.java @@ -1,16 +1,17 @@ package com.guo.learningprogresstracker.controller; import com.guo.learningprogresstracker.dto.request.CreateFragmentsRequest; +import com.guo.learningprogresstracker.dto.request.UpdateFragmentsRequest; import com.guo.learningprogresstracker.entity.CommonResult; +import com.guo.learningprogresstracker.entity.StudyReportFragmentsEntity; import com.guo.learningprogresstracker.exception.NotFindEntitiesException; import com.guo.learningprogresstracker.service.impl.StudyReportFragmentsServiceImpl; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.validation.annotation.Validated; -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; +import org.springframework.web.bind.annotation.*; + +import java.util.List; /** * 学习残片控制层 @@ -24,12 +25,29 @@ public class reportFragmentsController { /** * 创建学习残片 - * @param request - * @return */ @PostMapping public CommonResult createFragments(@Valid @RequestBody CreateFragmentsRequest request) throws NotFindEntitiesException { studyReportFragmentsServiceImpl.createFragments(request); return CommonResult.success(); } + + /** + * 更新学习残片 + */ + @PutMapping("/{id}") + public CommonResult updateFragments(@PathVariable Integer id, + @Valid @RequestBody UpdateFragmentsRequest request) throws NotFindEntitiesException { + studyReportFragmentsServiceImpl.updateFragments(id, request); + return CommonResult.success(); + } + + /** + * 获取指定会话的所有学习残片 + */ + @GetMapping("/session/{sessionNum}") + public CommonResult> getFragmentsBySession(@PathVariable String sessionNum) { + List fragments = studyReportFragmentsServiceImpl.getFragmentsBySession(sessionNum); + return CommonResult.success(fragments); + } }