fix:获取课程下一章节改为通过列表索引

This commit is contained in:
2026-08-06 17:44:27 +08:00
parent 83fc611574
commit df96d40a0e

View File

@@ -86,18 +86,21 @@ public class CourseCatalogueChapterServiceImpl extends ServiceImpl<CourseCatalog
@Override @Override
public Map<String, Object> getNextChapterDetail(Integer chapterId) { public Map<String, Object> getNextChapterDetail(Integer chapterId) {
CourseCatalogueChapterEntity currentChapter = this.getById(chapterId); CourseCatalogueChapterEntity currentChapter = this.getById(chapterId);
if (currentChapter==null) return null; if (currentChapter == null) {
return null;
}
CourseCatalogueChapterEntity nextChapter = this.getOne( // 复用目录章节列表,保证下一章顺序与列表接口完全一致
new LambdaQueryWrapper<CourseCatalogueChapterEntity>() List<CourseCatalogueChapterEntity> chapterList = getCourseCatalogueChapterList(currentChapter.getCatalogueId());
.eq(CourseCatalogueChapterEntity::getCatalogueId, currentChapter.getCatalogueId()) for (int i = 0; i < chapterList.size(); i++) {
.gt(CourseCatalogueChapterEntity::getSort, currentChapter.getSort() ) if (chapterId.equals(chapterList.get(i).getId())) {
.orderByAsc(CourseCatalogueChapterEntity::getSort) if (i + 1 >= chapterList.size()) {
.last("limit 1") return null;
); }
if (nextChapter==null) return null; return getChapterDetail(chapterList.get(i + 1).getId());
}
return getChapterDetail(nextChapter.getId()); }
return null;
} }