fix(lesson-plan): 优化学案生成文本及缓存时长
- 调整学案生成时异常提示文案为“学案正在生成,请耐心等待” - 缩短Redis缓存过期时间由12分钟改为7分钟,提高资源释放效率 - 修正生成标题中去除学生ID显示,避免冗余信息 - 将词汇列表转换为Word对象,隐藏单词展示内容以模拟填空效果 - 调整多轮练习词汇列表展示样式,统一处理单词显示 - 混合练习中隐藏词汇释义文本,防止提前泄露答案 - 保持数据结构适配前端练习需求,提升用户体验
This commit is contained in:
@@ -54,7 +54,7 @@ public class LessonPlanController {
|
||||
Integer wordSize = addLessonPlanReqVO.getWordSize();
|
||||
try {
|
||||
if (redisTemplate.opsForValue().get(LessonPlanConstant.buildGeneratePlanContent(studentId)) != null) {
|
||||
throw new RuntimeException("学案正常生成中");
|
||||
throw new RuntimeException("学案正在生成,请耐心等待");
|
||||
}
|
||||
taskExecutor.execute(() -> lessonPlanService.generateLessonPlans(studentId, unitId, wordSize));
|
||||
return Response.success("生成学案成功,请等待 10 分钟");
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.yinlihupo.enlish.service.constant.LessonPlanConstant;
|
||||
import com.yinlihupo.enlish.service.domain.dataobject.*;
|
||||
import com.yinlihupo.enlish.service.domain.mapper.*;
|
||||
import com.yinlihupo.enlish.service.model.bo.Sentence;
|
||||
import com.yinlihupo.enlish.service.model.bo.Word;
|
||||
import com.yinlihupo.enlish.service.service.LessonPlansService;
|
||||
import com.yinlihupo.enlish.service.utils.DifyClient;
|
||||
import com.yinlihupo.enlish.service.utils.StringToPlanMapUtil;
|
||||
@@ -55,7 +56,7 @@ public class LessonPlansServiceImpl implements LessonPlansService {
|
||||
public void generateLessonPlans(Integer studentId, Integer unitId, Integer wordSize) {
|
||||
String key = LessonPlanConstant.buildGeneratePlanContent(studentId);
|
||||
redisTemplate.opsForValue().set(key, studentId);
|
||||
redisTemplate.expire( key, 12, TimeUnit.MINUTES);
|
||||
redisTemplate.expire(key, 7, TimeUnit.MINUTES);
|
||||
|
||||
log.info("开始生成计划");
|
||||
List<VocabularyBankDO> vocabularyBankDOS = vocabularyBankDOMapper.selectVocabularyBankDOAllByUnitId(unitId);
|
||||
@@ -249,7 +250,7 @@ public class LessonPlansServiceImpl implements LessonPlansService {
|
||||
List<VocabularyBankDO> checkList,
|
||||
int day,
|
||||
GradeDO gradeDO, UnitDO unitDO, Integer studentId) throws Exception {
|
||||
String title = gradeDO.getTitle() + " " + unitDO.getTitle() + " " + "第" + day + "天" + studentId;
|
||||
String title = gradeDO.getTitle() + " " + unitDO.getTitle() + " " + "第" + day + "天";
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("title", title);
|
||||
data.put("syncVocabList", syncVocabList);
|
||||
@@ -259,13 +260,16 @@ public class LessonPlansServiceImpl implements LessonPlansService {
|
||||
data.put("checkListAns", checkList);
|
||||
|
||||
// 中译英
|
||||
List<VocabularyBankDO> drillRound1 = new ArrayList<>(syncVocabList);
|
||||
List<Word> list = syncVocabList.stream().map(vocabularyBankDO -> Word.builder().title(vocabularyBankDO.getWord()).definition(vocabularyBankDO.getDefinition()).build()).toList();
|
||||
list.forEach(word -> word.setTitle(" "));
|
||||
|
||||
List<Word> drillRound1 = new ArrayList<>(list);
|
||||
Collections.shuffle(drillRound1);
|
||||
data.put("drillRound1", drillRound1);
|
||||
List<VocabularyBankDO> drillRound2 = new ArrayList<>(syncVocabList);
|
||||
List<Word> drillRound2 = new ArrayList<>(list);
|
||||
Collections.shuffle(drillRound2);
|
||||
data.put("drillRound2", drillRound2);
|
||||
List<VocabularyBankDO> drillRound3 = new ArrayList<>(syncVocabList);
|
||||
List<Word> drillRound3 = new ArrayList<>(list);
|
||||
Collections.shuffle(drillRound3);
|
||||
data.put("drillRound3", drillRound3);
|
||||
|
||||
@@ -274,8 +278,10 @@ public class LessonPlansServiceImpl implements LessonPlansService {
|
||||
mixedDrill.addAll(syncVocabList);
|
||||
mixedDrill.addAll(gapVocabList);
|
||||
mixedDrill.addAll(reviewVocabList);
|
||||
Collections.shuffle(mixedDrill);
|
||||
data.put("mixedDrill", mixedDrill);
|
||||
List<Word> mixedList = new ArrayList<>(mixedDrill.stream().map(vocabularyBankDO -> Word.builder().title(vocabularyBankDO.getWord()).definition(vocabularyBankDO.getDefinition()).build()).toList());
|
||||
mixedList.forEach(word -> word.setDefinition(" "));
|
||||
Collections.shuffle(mixedList);
|
||||
data.put("mixedDrill", mixedList);
|
||||
|
||||
// 文章 A
|
||||
log.info("生成文章 A 中文开始");
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user