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