package com.securitycontrol.system.api.factory;

import com.securitycontrol.common.core.domain.Result;
import com.securitycontrol.common.core.web.page.TableDataInfo;
import com.securitycontrol.system.api.RemoteDecisionService;
import com.securitycontrol.system.api.domain.decision.qo.TeamChangeListQo;
import com.securitycontrol.system.api.domain.decision.vo.TeamChangeNumVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author HeiZi
 */
@Slf4j
@Component
public class RemoteDecisionFallbackFactory implements FallbackFactory<RemoteDecisionService> {

    @Override
    public RemoteDecisionService create(Throwable throwable) {

        log.error("分析决策服务调用失败:{}", throwable.getMessage());
        return new RemoteDecisionService() {

            @Override
            public Result<TeamChangeNumVo> getTeamNum(String startDate) {
                return Result.fail("查询计划班组变化告警失败:" + throwable.getMessage());

            }

            @Override
            public Result<TableDataInfo> queryByPage(TeamChangeListQo teamChangeListQo) {
                return Result.fail("查询注册用户信息失败:" + throwable.getMessage());
            }
        };

    }


}
