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.*; import java.util.List; /** * 学习残片控制层 */ @RequestMapping("/report-fragments") @RestController @Validated @RequiredArgsConstructor public class reportFragmentsController { private final StudyReportFragmentsServiceImpl studyReportFragmentsServiceImpl; /** * 创建学习残片 */ @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); } }