package com.xunmei.system.api.factory;

import com.xunmei.common.core.domain.R;
import com.xunmei.common.core.vo.IdNameVo;
import com.xunmei.system.api.Eto.OrgListByTypesConditionEto;
import com.xunmei.system.api.RemoteOrgService;
import com.xunmei.system.api.domain.SysOrg;
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 java.util.ArrayList;
import java.util.List;

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

    @Override
    public RemoteOrgService create(Throwable throwable) {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemoteOrgService() {
            @Override
            public R<List<SysOrg>> getAllOrg(String source) {
                return R.fail("获取获取机构失败:" + throwable.getMessage());
            }

            @Override
            public List<Long> selectCheckSubOrgIdList(Long orgId, String source) {
                return null;
            }

            @Override
            public SysOrg selectSysOrgById(Long id, String source) {
                return null;
            }

            @Override
            public List<SysOrg> selectSysOrgByParentId(Long id, String source) {
                return null;
            }

            @Override
            public R<List<SysOrg>> listByIds(List<Long> ids, String source) {
                return null;
            }

            @Override
            public R<List<Long>> findListByOrgType(Integer execOrgType, String source) {
                return null;
            }

            @Override
            public R<Boolean> batchSaveSyncOrg(List<SysOrg> orgList, String source) {
                return null;
            }

            @Override
            public R<List<SysOrg>> listByTypes(OrgListByTypesConditionEto eto) {
                return null;
            }

            @Override
            public SysOrg selectTopOrg(String source) {
                return null;
            }

            @Override
            public SysOrg selectOrgById(Long orgId, String source) {
                return null;
            }

            @Override
            public List<SysOrg> selectByOrgType(Integer orgType, String source) {
                return new ArrayList<>();
            }

            @Override
            public List<SysOrg> selectOrgByIdList(List<Long> orgList, String source) {
                return new ArrayList<>();
            }

            @Override
            public SysOrg getSysOrgByUserId(Long userId, String source) {
                return null;
            }

            @Override
            public List<Long> getUpOrgs(@PathVariable("orgId") Long orgId) {
                return new ArrayList<>();
            }
            @Override
            public List<IdNameVo> getParentName(List<Long> ids){
                return  new ArrayList<>();
            }

            @Override
            public List<SysOrg> findAllOrg(String source) {
                return null;
            }
        };
    }
}
