diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/controller/RepoBizController.java b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/controller/RepoBizController.java index 93dd51e7..aee92008 100644 --- a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/controller/RepoBizController.java +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/controller/RepoBizController.java @@ -21,10 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; @@ -79,7 +76,34 @@ public class RepoBizController { @Operation(summary = "查询题库下题目") public Result> questionList(@PathVariable String repoId) { List list = questionRepoService.questionList(repoId); - return Result.ok(questionService.listByIds(list)); + List questions = questionService.listByIds(list); + //获取复选题id + List type5Ids = questions.stream() + .filter(question -> question.getType() == 5) + .map(Question::getId) + .collect(Collectors.toList()); + //获取复选题所包含的题目 + List type5Questions = new ArrayList<>(); + if (!type5Ids.isEmpty()) { + type5Questions = questionService.list( + new LambdaQueryWrapper() + .in(Question::getParentId, type5Ids) + ); + } + // 创建一个映射,用于快速查找父ID对应的子题目 + Map> parentToChildrenMap = type5Questions.stream() + .collect(Collectors.groupingBy(Question::getParentId)); + + // 将子题目添加到原始列表中,保持原有顺序 + List resultQuestions = new ArrayList<>(); + for (Question question : questions) { + resultQuestions.add(question); + if (question.getType() == 5) { + List children = parentToChildrenMap.getOrDefault(question.getId(), Collections.emptyList()); + resultQuestions.addAll(children); + } + } + return Result.ok(resultQuestions); } @GetMapping("course_list") diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/question/controller/QuestionController.java b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/question/controller/QuestionController.java index b7262f81..08921abe 100644 --- a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/question/controller/QuestionController.java +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/question/controller/QuestionController.java @@ -119,6 +119,7 @@ public class QuestionController extends JeecgController delete(@RequestParam(name="id",required=true) String id) { Question question = questionService.getById(id); questionService.removeById(id);