fix(examWords): 处理生成单词为空的异常情况
- 增加判断如果生成的单词对象为空或单词列表为空,则抛出运行时异常 - 防止后续处理中因单词缺失导致的错误 - 提升系统稳定性与异常提示的准确性
This commit is contained in:
@@ -50,6 +50,9 @@ public class ExamWordsController {
|
||||
}
|
||||
try {
|
||||
ExamWordsDO examWordsDO = examWordsService.generateExamWords(gradeId, level, studentIds);
|
||||
if (examWordsDO == null || examWordsDO.getWordIds().isEmpty()) {
|
||||
throw new RuntimeException("没有单词");
|
||||
}
|
||||
List<VocabularyBankDO> vocabularyBankDOS = vocabularyService.findVocabularyBankDOListById(examWordsDO.getWordIds());
|
||||
List<Word> assessmentWords = vocabularyBankDOS.stream().map(vocabularyBankDO -> Word.builder()
|
||||
.id(vocabularyBankDO.getId())
|
||||
|
||||
Reference in New Issue
Block a user