Administrator
2025-08-28 080d73694200c6c6e63b26fb21e125d927b026ca
refactor(ai): 用 FebsException 替代 RuntimeException

-将 AI 服务中的 RuntimeException 替换为 FebsException
-优化了异常处理,提高了错误信息的准确性和可维护性
1 files modified
11 ■■■■ changed files
src/main/java/cc/mrbird/febs/ai/service/impl/AiMemberAnswerServiceImpl.java 11 ●●●● patch | view | raw | blame | history
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();