package com.sptg.device.api.feigns.fallback;

import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.device.api.feigns.DeviceLogFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * title: DeviceLogFeignFallbackFactory
 * package: com.sptg.device.api.feigns.fallback
 * description:
 */
@Component
@Slf4j
public class DeviceLogFeignFallbackFactory implements FallbackFactory<DeviceLogFeign> {

    @Override
    public DeviceLogFeign create(Throwable cause) {
        return (deviceLog) -> {
            log.error(cause.getMessage(),cause);
            return new ResultBean<>(ResultEnum.ERROR);
        };
    }

}
