package com.jeeplus.mail.factory;

import com.jeeplus.mail.feign.IMailApi;
import com.jeeplus.sys.service.dto.UserDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 用户服务降级处理
 *
 * @author jeeplus
 */
@Slf4j
@Component
public class MailApiFallbackFactory implements FallbackFactory <IMailApi> {

    @Override
    public IMailApi create(Throwable throwable) {
        log.error ( "站内信服务调用失败:{}", throwable.getMessage ( ) );
        return new IMailApi ( ) {

            @Override
            public void sendEmail(List <UserDTO> receivers, String title, String content) {
            }
        };
    }
}
