From 0f0a6137ffdded23996a82a58a071cd0aea7069f Mon Sep 17 00:00:00 2001 From: luoweijian <1329394916@qq.com> Date: Wed, 15 Jul 2026 09:53:48 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/GenerateClassicPaperDomainServiceImpl.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/project/classicpaper/domain/service/impl/GenerateClassicPaperDomainServiceImpl.java b/src/main/java/com/project/classicpaper/domain/service/impl/GenerateClassicPaperDomainServiceImpl.java index 747e2d0..3dddfc2 100644 --- a/src/main/java/com/project/classicpaper/domain/service/impl/GenerateClassicPaperDomainServiceImpl.java +++ b/src/main/java/com/project/classicpaper/domain/service/impl/GenerateClassicPaperDomainServiceImpl.java @@ -29,6 +29,7 @@ import com.project.question.domain.entity.TaskKnowledgePointEntity; import com.project.question.domain.service.TaskKnowledgeClusterBaseService; import com.project.question.domain.service.TaskKnowledgePointBaseService; import com.project.task.domain.enums.QuestionTypeEnum; +import io.vavr.control.Try; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -36,6 +37,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.*; +import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; @Service @@ -129,6 +131,9 @@ public class GenerateClassicPaperDomainServiceImpl implements GenerateClassicPap if (totalPerSet <= 0) { throw new BusinessErrorException("至少需要一种题型的数量大于0"); } + if (totalPerSet > 100) { + throw new BusinessErrorException("总题数不得超过100题"); + } // 校验:单选题+判断题 <= 知识点总数 int singleAndTrueFalse = Optional.ofNullable(request.getSingleChoiceNum()).orElse(0) @@ -359,9 +364,10 @@ public class GenerateClassicPaperDomainServiceImpl implements GenerateClassicPap for (PaperQuestionTask task : paperQuestionTasks) { Long clusterId = task.knowledgePoints != null && !task.knowledgePoints.isEmpty() ? task.knowledgePoints.get(0).getClusterId() : null; - classicPaperQuestionGenerator.generateAsync( + CompletableFuture.runAsync(() -> Try.run(() -> classicPaperQuestionGenerator.generateAsync( task.paperQuestionId, task.knowledgePoints, task.questionType, - 1 + sparePerQuestion, clusterId); + 1 + sparePerQuestion, clusterId))); + } // ============ Phase 3: 立即返回 ============