feat: 新增碎片更新和会话查询的Controller端点
- PUT /report-fragments/{id} 更新碎片内容
- GET /report-fragments/session/{sessionNum} 获取指定会话的完整碎片列表
This commit is contained in:
+24
-6
@@ -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<Void> createFragments(@Valid @RequestBody CreateFragmentsRequest request) throws NotFindEntitiesException {
|
||||
studyReportFragmentsServiceImpl.createFragments(request);
|
||||
return CommonResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新学习残片
|
||||
*/
|
||||
@PutMapping("/{id}")
|
||||
public CommonResult<Void> updateFragments(@PathVariable Integer id,
|
||||
@Valid @RequestBody UpdateFragmentsRequest request) throws NotFindEntitiesException {
|
||||
studyReportFragmentsServiceImpl.updateFragments(id, request);
|
||||
return CommonResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定会话的所有学习残片
|
||||
*/
|
||||
@GetMapping("/session/{sessionNum}")
|
||||
public CommonResult<List<StudyReportFragmentsEntity>> getFragmentsBySession(@PathVariable String sessionNum) {
|
||||
List<StudyReportFragmentsEntity> fragments = studyReportFragmentsServiceImpl.getFragmentsBySession(sessionNum);
|
||||
return CommonResult.success(fragments);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user