package com.xhpc.common.api.factory;

import com.xhpc.common.api.SmsService;
import com.xhpc.common.core.domain.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * program: ruoyi
 * User: HongYun
 * Date:2021-08-16 17
 */
@Component
public class SmsFallbackFactory implements FallbackFactory<SmsService> {

    private static final Logger logger = LoggerFactory.getLogger(SmsFallbackFactory.class);
    @Override
    public SmsService create(Throwable cause) {
        logger.error("短信发送服务调用失败:{} //fallback", cause.getMessage());
        return new SmsService() {
            @Override
            public R sendNotice(Map<String, String> paramMap) {

                return R.fail(3886,"短信发送失败:" + cause.getMessage());
            }
        };
    }
}
