luodangjia
2024-09-24 7b55e2cd82647b87d79a778ed70fdbddb39ac00a
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/factory/ChargingGunFallbackFactory.java
@@ -4,8 +4,11 @@
import com.ruoyi.chargingPile.api.feignClient.ChargingPileClient;
import com.ruoyi.chargingPile.api.model.TChargingGun;
import com.ruoyi.chargingPile.api.model.TChargingPile;
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;
@@ -35,13 +38,30 @@
    
            @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
            public R<SiteNameVO> getAllInfoById(Integer id) {
                return R.fail("通过枪id获取站点、桩、枪的名称失败:" + throwable.getMessage());
            }
            @Override
            public R<TChargingGun> getChargingGunByCode(String code) {
                return R.fail("根据枪编号获取充电枪失败:" + throwable.getMessage());
            }
            @Override
            public R<String> updateChargingGunById(TChargingGun chargingGun) {
                return R.fail("编辑充电枪失败:" + throwable.getMessage());
            }
        };
    }
}