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

import com.sptg.permissions.api.entity.SmsTemplate;
import com.sptg.permissions.api.feigns.SmsTemplateFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author zwx
 * @create 2020/11/2 15:42
 */
@Component
@Slf4j
public class SmsTemplateFallbackFactory implements FallbackFactory<SmsTemplateFeign> {
    @Override
    public SmsTemplateFeign create(Throwable cause) {
        return new SmsTemplateFeign() {
            @Override
            public SmsTemplate getByCode(String code) {
                log.error(cause.getMessage(), cause);
                return null;
            }
        };
    }
}
