package com.usky.iot.factory;

import com.usky.common.core.exception.FeignBadRequestException;
import com.usky.iot.RemoteIotService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;


/**
 * 用户服务降级处理
 *
 * @author ruoyi
 */
@Component
public class RemoteIotFactory implements FallbackFactory<RemoteIotService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteIotFactory.class);

    @Override
    public RemoteIotService create(Throwable throwable)
    {
        return new RemoteIotService()
        {
            @Override
            public void executeTimedSendingOld() {
                log.error("工作报告定时发送异常:{}", throwable.getMessage());
                throw new FeignBadRequestException(500,"工作报告定时发送异常"+throwable.getMessage());
            }

            @Override
            public void reportSubmissionReminderOld() {
                log.error("工作报告提交提醒发送异常:{}", throwable.getMessage());
                throw new FeignBadRequestException(500,"工作报告提交提醒发送异常"+throwable.getMessage());
            }

        };
    }
}
