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 |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 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
new file mode 100644
index 0000000..2f57fab
--- /dev/null
+++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsFallbackFactory.java
@@ -0,0 +1,32 @@
+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;
+import org.springframework.cloud.openfeign.FallbackFactory;
+import org.springframework.stereotype.Component;
+
+/**
+ * @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() {
+			
+			@Override
+			public R<TGoods> getGoodsById(Integer id) {
+				return R.fail("根据id获取商品信息失败:" + throwable.getMessage());
+			}
+		};
+	}
+	
+}

--
Gitblit v1.7.1