package com.vctgo.system.api.factory;

import com.vctgo.common.core.domain.R;
import com.vctgo.system.api.RemoteClassSettingService;
import com.vctgo.system.api.domain.dto.ObserveChildhoodDto;
import com.vctgo.system.api.domain.dto.ObserveChildhoodNewDto;
import com.vctgo.system.api.domain.dto.ObserverTreeClassChildDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

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

    @Override
    public RemoteClassSettingService create(Throwable throwable) {
        log.error("查询幼儿服务调用失败:{}", throwable.getMessage());
        return new RemoteClassSettingService() {
            @Override
            public R<List<ObserverTreeClassChildDto>> getChildhoodList(ObserveChildhoodNewDto observeChildhoodDto) {
                return R.fail("查询幼儿列表信息失败:" + throwable.getMessage());
            }

        };
    }
}
