From cc788c86acd2983d791fbd3e50a9b30335b91953 Mon Sep 17 00:00:00 2001 From: zhibing.pu <393733352@qq.com> Date: 星期六, 24 八月 2024 15:35:19 +0800 Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/mx_charging_pile --- ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsFallbackFactory.java | 34 ++++++++++++++++++++-------------- 1 files changed, 20 insertions(+), 14 deletions(-) diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsFallbackFactory.java index f257843..2f57fab 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsFallbackFactory.java @@ -1,5 +1,7 @@ package com.ruoyi.other.api.factory; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.other.api.domain.TGoods; import com.ruoyi.other.api.feignClient.GoodsClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -7,20 +9,24 @@ import org.springframework.stereotype.Component; /** - * 商品服务降级处理 - * - * @author ruoyi + * @author zhibing.pu + * @Date 2024/8/16 13:48 */ @Component -public class GoodsFallbackFactory implements FallbackFactory<GoodsClient> -{ - private static final Logger log = LoggerFactory.getLogger(GoodsFallbackFactory.class); - - @Override - public GoodsClient create(Throwable throwable) { - log.error("商品调用失败:{}", throwable.getMessage()); - return new GoodsClient() { - - }; - } +public class GoodsFallbackFactory implements FallbackFactory<GoodsClient> { + + private static final Logger log = LoggerFactory.getLogger(GoodsFallbackFactory.class); + + @Override + public GoodsClient create(Throwable throwable) { + log.error("商品调用失败:{}", throwable.getMessage()); + return new GoodsClient() { + + @Override + public R<TGoods> getGoodsById(Integer id) { + return R.fail("根据id获取商品信息失败:" + throwable.getMessage()); + } + }; + } + } -- Gitblit v1.7.1