package com.usky.pm.factory;

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


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

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

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

        };
    }
}
