无关风月
2024-09-26 9a1173507d06c59a7c02e92ad083073e0036eadc
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/factory/ChargingGunFallbackFactory.java
@@ -7,6 +7,8 @@
import com.ruoyi.chargingPile.api.model.TFaultMessage;
import com.ruoyi.chargingPile.api.vo.SiteNameVO;
import com.ruoyi.common.core.domain.R;
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<TChargingGun> getChargingGunById(Integer id) {
                throw new RuntimeException("根据id获取充电枪失败:" + throwable.getMessage());
                // 手动进行全局事务回滚
                try {
                    GlobalTransactionContext.getCurrent().rollback();
                } catch (TransactionException e) {
                    throw new RuntimeException(e);
                }
                return R.fail("根据id获取充电枪失败:" + throwable.getMessage());
            }
            @Override
@@ -49,6 +57,11 @@
                return R.fail("根据枪编号获取充电枪失败:" + throwable.getMessage());
            }
            @Override
            public R<String> updateChargingGunById(TChargingGun chargingGun) {
                return R.fail("编辑充电枪失败:" + throwable.getMessage());
            }
        };
    }
}