From 080d73694200c6c6e63b26fb21e125d927b026ca Mon Sep 17 00:00:00 2001 From: Administrator <15274802129@163.com> Date: Thu, 28 Aug 2025 09:55:53 +0800 Subject: [PATCH] refactor(ai): 用 FebsException 替代 RuntimeException --- src/main/java/cc/mrbird/febs/ai/service/impl/AiMemberAnswerServiceImpl.java | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/cc/mrbird/febs/ai/service/impl/AiMemberAnswerServiceImpl.java b/src/main/java/cc/mrbird/febs/ai/service/impl/AiMemberAnswerServiceImpl.java index 58c9830..5ba0dd9 100644 --- a/src/main/java/cc/mrbird/febs/ai/service/impl/AiMemberAnswerServiceImpl.java +++ b/src/main/java/cc/mrbird/febs/ai/service/impl/AiMemberAnswerServiceImpl.java @@ -9,6 +9,7 @@ import cc.mrbird.febs.ai.service.*; import cc.mrbird.febs.ai.utils.UUID; import cc.mrbird.febs.common.entity.FebsResponse; +import cc.mrbird.febs.common.exception.FebsException; import cc.mrbird.febs.common.utils.LoginUserUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUnit; @@ -61,7 +62,7 @@ String productId = dto.getId(); AiProduct aiProduct = aiProductService.getById(productId); if(ObjectUtil.isNull(aiProduct)){ - throw new RuntimeException("产品不存在"); + throw new FebsException("产品不存在"); } //验证产品分类下是否有题目 String productCategoryId = aiProduct.getProductCategoryId(); @@ -72,7 +73,7 @@ List<AiProductQuestion> aiProductQuestions = aiProductQuestionService.getListByQuery(questionLambdaQueryWrapper); if(CollUtil.isEmpty(aiProductQuestions)){ // todo 没有题目采用AI生成题目 - throw new RuntimeException("产品没有题目"); + throw new FebsException("产品没有题目"); } //判断该产品是否有正在进行的练习 Date createdTime = new Date(); @@ -134,7 +135,7 @@ String productId = dto.getId(); AiProduct aiProduct = aiProductService.getById(productId); if(ObjectUtil.isNull(aiProduct)){ - throw new RuntimeException("产品不存在"); + throw new FebsException("产品不存在"); } //验证产品分类下是否有题目 String productCategoryId = aiProduct.getProductCategoryId(); @@ -145,7 +146,7 @@ List<AiProductQuestion> aiProductQuestions = aiProductQuestionService.getListByQuery(questionLambdaQueryWrapper); if(CollUtil.isEmpty(aiProductQuestions)){ // todo 没有题目采用AI生成题目 - throw new RuntimeException("产品没有题目"); + throw new FebsException("产品没有题目"); } //判断该产品是否有正在进行的练习 Date createdTime = new Date(); @@ -246,7 +247,7 @@ AiMemberAnswer aiMemberAnswer = this.getById(memberAnswerId); if(ObjectUtil.isNull(aiMemberAnswer)){ - throw new RuntimeException("答题记录不存在"); + throw new FebsException("答题记录不存在"); } Date createdTime = new Date(); -- Gitblit v1.9.1