package com.hxhq.system.api.factory;

import com.hxhq.common.core.domain.R;
import com.hxhq.common.core.web.domain.AjaxResult;
import com.hxhq.system.api.RemoteIntegrationService;
import com.hxhq.system.api.RemoteUserService;
import com.hxhq.system.api.domain.SysUser;
import com.hxhq.system.api.model.LoginUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

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

    @Override
    public RemoteIntegrationService create(Throwable throwable)
    {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemoteIntegrationService()
        {
            @Override
            public AjaxResult validate(String username, String password) {
                return AjaxResult.error("验证用户用户名密码失败"+ throwable.getMessage());
            }

            @Override
            public AjaxResult checkAccountExists(String username) {
                return AjaxResult.error("检查用户失败"+ throwable.getMessage());
            }
        };
    }
}
