package com.bawei.es.remote.factory;

import com.bawei.common.core.domain.R;
import com.bawei.common.core.web.domain.AjaxResult;
import com.bawei.es.remote.EsDocRemoteService;
import lombok.extern.log4j.Log4j2;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

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

@Component
@Log4j2
public class EsDocRemoteFactory implements FallbackFactory<EsDocRemoteService> {
    @Override
    public EsDocRemoteService create(Throwable cause) {
        return new EsDocRemoteService() {
            @Override
            public R queryList(String indexName, Map<String, Object> docMsg) {
                log.error("调用查询信息远程服务失败{}-{}-{}-{}",indexName,docMsg,cause.getMessage(),cause);
                return R.fail();
            }

            @Override
            public R batchAddDoc(String indexName, Map<String, Object> docMsg) {
                log.error("调用批量添加信息远程服务失败{}-{}-{}",indexName,cause.getMessage(),cause);
                return R.fail();
            }

            @Override
            public R bathDeleteDoc(String indexName, List<String> ids) {
                log.error("调用批量删除信息远程服务失败{}-{}-{}-{}",indexName,ids,cause.getMessage(),cause);
                return R.fail();
            }
        };
    }
}
