From 7b55e2cd82647b87d79a778ed70fdbddb39ac00a Mon Sep 17 00:00:00 2001
From: luodangjia <luodangjia>
Date: 星期二, 24 九月 2024 13:44:26 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsFallbackFactory.java |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 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 e9002f4..bb82c32 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
@@ -3,6 +3,8 @@
 import com.ruoyi.common.core.domain.R;
 import com.ruoyi.other.api.domain.TGoods;
 import com.ruoyi.other.api.feignClient.GoodsClient;
+import io.seata.core.exception.TransactionException;
+import io.seata.tm.api.GlobalTransactionContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.cloud.openfeign.FallbackFactory;
@@ -36,7 +38,13 @@
 			
 			@Override
 			public R updateGoods(TGoods goods) {
-				throw new RuntimeException("修改商品异常");
+				// 手动进行全局事务回滚
+				try {
+					GlobalTransactionContext.getCurrent().rollback();
+				} catch (TransactionException e) {
+					throw new RuntimeException(e);
+				}
+				return R.fail("修改商品异常");
 			}
 		};
 	}

--
Gitblit v1.7.1