d5835cdf55
- PUT /report-fragments/{id} 更新碎片内容
- GET /report-fragments/session/{sessionNum} 获取指定会话的完整碎片列表
54 lines
2.0 KiB
Java
54 lines
2.0 KiB
Java
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<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);
|
|
}
|
|
}
|