package com.yuchen.saas.park.api.feign.service.pay;

import com.yuchen.saas.park.api.entity.park.PmgBatParkXCPayInfo;
import org.nest.springwrap.core.tool.api.R;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @Author: 肖润飞
 * @CreateTime: 2022/11/15 16:32
 * @Description: TODO
 * @Version: 1.0
 */
@Component
public class XCPayInfoFeignServiceFallback implements FallbackFactory<XCPayInfoFeignService> {

    @Override
    public XCPayInfoFeignService create(Throwable cause) {
        return new XCPayInfoFeignService() {

            @Override
            public R<PmgBatParkXCPayInfo> get(Long parkId) {
                if (cause != null) {
                    String message = cause.getMessage();
                    return R.error(message);
                }
                return R.error("调用接口错误，熔断机制！");
            }

            @Override
            public R<PmgBatParkXCPayInfo> getByOidPartner(String oidPartner) {
                if (cause != null) {
                    String message = cause.getMessage();
                    return R.error(message);
                }
                return R.error("调用接口错误，熔断机制！");
            }
        };
    }
}