package com.yuchen.saas.parking.api.feign;

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

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

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

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