package com.bonus.system.api.factory;

import com.bonus.common.core.constant.HttpStatus;
import com.bonus.common.core.domain.R;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.web.page.TableDataInfo;
import com.bonus.system.api.RemoteSbdUserService;
import com.bonus.system.api.RemoteUserService;
import com.bonus.system.api.domain.SysDept;
import com.bonus.system.api.domain.SysUser;
import com.bonus.system.api.model.LoginUser;
import com.bonus.system.api.model.SbdUser;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

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

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

            @Override
            public R<SbdUser> getInfo(String username, String source) {
                return R.fail("获取送变电用户失败:" + throwable.getMessage());
            }
        };
    }
}
