package com.muyu.enterprise.remote.factory;

import com.muyu.common.core.domain.Result;
import com.muyu.common.system.domain.SysUser;
import com.muyu.common.system.remote.factory.RemoteFileFallbackFactory;
import com.muyu.enterprise.remote.RemoteFirmUserService;
import lombok.extern.log4j.Log4j2;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @Author：杨鹏
 * @Package：com.muyu.enterprise.remote.factory
 * @Project：cloud-vehicle
 * @name：RemoteFirmUserFallbackFactory
 * @Date：2024/10/8 20:01
 */
@Component
@Log4j2
public class RemoteFirmUserFallbackFactory implements FallbackFactory<RemoteFirmUserService>
{
    @Override
    public RemoteFirmUserService create(Throwable cause) {
        log.error("文件服务调用失败:{}", cause.getMessage());
        return new RemoteFirmUserService() {
            @Override
            public Result<SysUser> queryByUsername(String username, String source,String databaseName) {
                return Result.error("saas连接失败:" + cause.getMessage());
            }
        };
    }
}
