package com.ruoyi.system.api.factory;

import com.ruoyi.system.api.RemoteDeptService;
import com.ruoyi.system.api.domain.SysDept;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 组织机构服务降级处理
 * 
 * @author ruoyi
 */
@Component
public class RemoteDeptFallbackFactory implements FallbackFactory<RemoteDeptService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteDeptFallbackFactory.class);

    @Override
    public RemoteDeptService create(Throwable throwable)
    {
        log.error("组织机构服务调用失败:{}", throwable.getMessage());
        return new RemoteDeptService()
        {
            @Override
            public List<SysDept> getAllDeptList() {
                return null;
            }

            @Override
            public List<SysDept> getSubDeptList(Long deptId) {
                return null;
            }

            @Override
            public int editFactoryCode(Long deptId, String factoryCode) {
                return 0;
            }

        };
    }
}
