feat(review): 新增复习内容滚动展示与交互 API

- 新增 /review/feed 端点,合并报告和残片数据按时间倒序返回
- 新增 /review/report/{id} 和 /review/fragment/{id} 端点
- 支持复习内容在首页滚动展示及点击查看详情
This commit is contained in:
2026-05-23 19:22:55 +08:00
parent a7cb4a1167
commit 375ec8858c
6 changed files with 192 additions and 0 deletions
@@ -0,0 +1,29 @@
package com.guo.learningprogresstracker.service;
import com.guo.learningprogresstracker.dto.ReviewFeedItem;
import com.guo.learningprogresstracker.entity.StudyReportFragmentsEntity;
import com.guo.learningprogresstracker.entity.StudyReportsEntity;
import com.guo.learningprogresstracker.exception.NotFindEntitiesException;
import java.util.List;
/**
* 复习模块 Service 接口
*/
public interface ReviewService {
/**
* 获取复习 feed 列表,合并报告和残片按时间倒序
*/
List<ReviewFeedItem> getReviewFeed(int limit);
/**
* 获取报告详情
*/
StudyReportsEntity getReportDetail(int id) throws NotFindEntitiesException;
/**
* 获取残片详情
*/
StudyReportFragmentsEntity getFragmentDetail(int id) throws NotFindEntitiesException;
}
@@ -0,0 +1,44 @@
package com.guo.learningprogresstracker.service.impl;
import com.guo.learningprogresstracker.dto.ReviewFeedItem;
import com.guo.learningprogresstracker.entity.StudyReportFragmentsEntity;
import com.guo.learningprogresstracker.entity.StudyReportsEntity;
import com.guo.learningprogresstracker.exception.NotFindEntitiesException;
import com.guo.learningprogresstracker.mapper.ReviewMapper;
import com.guo.learningprogresstracker.mapper.StudyReportFragmentsMapper;
import com.guo.learningprogresstracker.mapper.StudyReportsMapper;
import com.guo.learningprogresstracker.service.ReviewService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
/**
* 复习模块 Service 实现
*/
@Service
@RequiredArgsConstructor
public class ReviewServiceImpl implements ReviewService {
private final ReviewMapper reviewMapper;
private final StudyReportsMapper studyReportsMapper;
private final StudyReportFragmentsMapper studyReportFragmentsMapper;
@Override
public List<ReviewFeedItem> getReviewFeed(int limit) {
return reviewMapper.selectReviewFeed(limit);
}
@Override
public StudyReportsEntity getReportDetail(int id) throws NotFindEntitiesException {
return Optional.ofNullable(studyReportsMapper.selectById(id))
.orElseThrow(() -> new NotFindEntitiesException("学习报告[" + id + "]不存在"));
}
@Override
public StudyReportFragmentsEntity getFragmentDetail(int id) throws NotFindEntitiesException {
return Optional.ofNullable(studyReportFragmentsMapper.selectById(id))
.orElseThrow(() -> new NotFindEntitiesException("学习残片[" + id + "]不存在"));
}
}