package com.usky.system.factory;

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

import java.util.List;
import java.util.Map;

/**
 * @author han
 * @date 2023/12/08 11:07
 */
@Component
public class RemoteDeptFallbackFactory implements FallbackFactory<RemoteDeptService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteUserFallbackFactory.class);

    @Override
    public RemoteDeptService create(Throwable throwable)
    {
        log.error("部门服务调用失败:{}", throwable.getMessage());
        return new RemoteDeptService()
        {
            @Override
            public List<Map<String, Object>> getDeptList(Integer tenantId) {
                throw new FeignBadRequestException(500,"获取部门异常"+throwable.getMessage());
            }
        };
    }
}
