package com.xueyi.nlt.api.nlt.feign.factory;

import com.xueyi.common.core.web.result.AjaxResult;
import com.xueyi.nlt.api.nlt.domain.vo.KnowledgeVo;
import com.xueyi.nlt.api.nlt.feign.RemoteQAService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 会议室服务 降级处理
 *
 * @author xueyi
 */
@Slf4j
@Component
public class RemoteQAFallbackFactory implements FallbackFactory<RemoteQAService> {

    @Override
    public RemoteQAService create(Throwable throwable) {
        log.error("短信服务调用失败:{}", throwable.getMessage());
        return new RemoteQAService() {
            @Override
            public AjaxResult query(String manCode, String question, Long tenantId) {
                return AjaxResult.error("查询失败");
            }

            @Override
            public AjaxResult query(KnowledgeVo vo) {
                return AjaxResult.error("查询失败");
            }
        };
    }
}