package com.bawei.es.remote.factory;

import com.bawei.common.core.domain.R;
import com.bawei.es.remote.api.RemoteDocumentService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * 文件服务降级处理
 *
 * @author bawei
 */
@Component
public class RemoteDocumentFallbackFactory implements FallbackFactory<RemoteDocumentService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteDocumentFallbackFactory.class);


    @Override
    public RemoteDocumentService create(Throwable cause) {
        return new RemoteDocumentService() {
            @Override
            public R queryList(String indexName, Map<String, Object> conditions) {
                return R.fail();
            }

            @Override
            public R batchDocument(String indexName, List<String> dataJson) {
                return R.fail();
            }

            @Override
            public R batchDeleteDocument(String indexName, List<String> dataJson) {
                return R.fail();
            }
        };
    }
}
