diff --git a/src/main/java/com/project/appeal/domain/dto/AppealDTO.java b/src/main/java/com/project/appeal/domain/dto/AppealDTO.java index c980698..3452279 100644 --- a/src/main/java/com/project/appeal/domain/dto/AppealDTO.java +++ b/src/main/java/com/project/appeal/domain/dto/AppealDTO.java @@ -20,6 +20,8 @@ public class AppealDTO extends BaseDTO { private Long questionId; private String questionContent; //题干 private Integer questionSort; //题号 + private String questionTypeText; //题型 + private Integer questionType;//题型 private String kpContentsStr; //知识点文本 private List kpIdList; private String rightAnswer;//正确答案 diff --git a/src/main/java/com/project/appeal/domain/service/Impl/SearchAppealDomainServiceImpl.java b/src/main/java/com/project/appeal/domain/service/Impl/SearchAppealDomainServiceImpl.java index 9069f2a..6370171 100644 --- a/src/main/java/com/project/appeal/domain/service/Impl/SearchAppealDomainServiceImpl.java +++ b/src/main/java/com/project/appeal/domain/service/Impl/SearchAppealDomainServiceImpl.java @@ -127,6 +127,8 @@ public class SearchAppealDomainServiceImpl implements SearchAppealDomainService appealDTO.setScoreStr(scoreStr); appealDTO.setQuestionContent(questionDetail.getQuestionContent()); + appealDTO.setQuestionType(questionDetail.getType()); + appealDTO.setQuestionTypeText(Objects.requireNonNull(QuestionTypeEnum.findByValue(questionDetail.getType())).getDescription()); appealDTO.setKpIdList(questionEntity.getKpIdList()); kpIdSet.addAll(questionEntity.getKpIdList()); diff --git a/src/main/java/com/project/classicpaper/application/impl/ClassicCategoryApplicationServiceImpl.java b/src/main/java/com/project/classicpaper/application/impl/ClassicCategoryApplicationServiceImpl.java index c851ab1..29881ca 100644 --- a/src/main/java/com/project/classicpaper/application/impl/ClassicCategoryApplicationServiceImpl.java +++ b/src/main/java/com/project/classicpaper/application/impl/ClassicCategoryApplicationServiceImpl.java @@ -41,30 +41,26 @@ public class ClassicCategoryApplicationServiceImpl implements ClassicCategoryApp ClassicCategoryDTO::getParentId, ClassicCategoryDTO::setChildrenList); - // 3. 查询所有套题组(只查必要字段),同时用于统计数量和填充列表 + // 3. 查询套题组,统计数量和分组 List allPaperSets = classicPaperSetBaseService.lambdaQuery() - .select(ClassicPaperSetEntity::getClassicCategoryId,ClassicPaperSetEntity::getId, ClassicPaperSetEntity::getName) - .orderByDesc(ClassicPaperSetEntity::getId) - .list(); + .select(ClassicPaperSetEntity::getClassicCategoryId, ClassicPaperSetEntity::getId, ClassicPaperSetEntity::getName) + .orderByDesc(ClassicPaperSetEntity::getId).list(); Map countMap = new HashMap<>(); + Map> paperSetMap = Boolean.TRUE.equals(withPaperSet) ? new HashMap<>() : null; for (ClassicPaperSetEntity set : allPaperSets) { Long catId = set.getClassicCategoryId(); - if (catId != null) { - countMap.merge(catId, 1, Integer::sum); + if (catId == null) continue; + countMap.merge(catId, 1, Integer::sum); + if (paperSetMap != null) { + //按分类ID分组套题组 + paperSetMap.computeIfAbsent(catId, k -> new ArrayList<>()).add(set.toDTO(ClassicPaperSetDTO::new)); } } // 4. 注入 paperSetCount 到树节点 injectPaperSetCount(tree, countMap); - - if (Boolean.TRUE.equals(withPaperSet)) { - // 5. 按分类ID分组套题组 - Map> paperSetMap = allPaperSets.stream() - .filter(s -> s.getClassicCategoryId() != null) - .map(s -> s.toDTO(ClassicPaperSetDTO::new)) - .collect(Collectors.groupingBy(ClassicPaperSetDTO::getClassicCategoryId)); - - // 6. 注入套题组到二级分类 + if (paperSetMap != null){ + // 5. 注入套题组到二级分类 injectPaperList(tree, paperSetMap); }