package com.siwei.system.api.factory;

import com.siwei.common.core.constant.SecurityConstants;
import com.siwei.common.core.domain.R;
import com.siwei.system.api.RemoteDeptService;
import com.siwei.system.api.RemoteUserService;
import com.siwei.system.api.domain.SysDept;
import com.siwei.system.api.domain.SysUser;
import com.siwei.system.api.model.LoginUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;

import java.util.List;

/**
 * 用户服务降级处理
 *
 * @author siwei-zhx
 */
@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 R<List<SysDept>> childByDeptId(Long deptId, Boolean isTree, String source) {
                return R.fail("获取失败:" + throwable.getMessage());
            }

        };
    }
}
