package com.muyu.analysis.parsing.remote.factory;

import com.muyu.analysis.parsing.remote.RemoteClientService;
import com.muyu.common.core.domain.Result;
import com.muyu.enterprise.domain.resp.car.MessageValueListResp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 报文模版对象服务降级处理
 * @Author：李庆帅
 * @Package：com.muyu.analysis.parsing.remote.factory
 * @Project：cloud-server
 * @name：RemoteServiceClientFactory
 * @Date：2024/9/28 21:16
 */
@Component
public class RemoteClientServiceFactory
        implements FallbackFactory<RemoteClientService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteClientServiceFactory.class);

    @Override
    public RemoteClientService create(Throwable throwable) {
        log.error("报文模版传参调用失败:{}", throwable.getMessage());
        return new RemoteClientService(){

            @Override
            public Result<Long> findByVehicleVin(String vehicleVin) {
                return Result.error("报文模版传参调用失败" + throwable.getMessage());
            }

            @Override
            public Result<List<MessageValueListResp>> findByTemplateId(Long templateId) {
                return Result.error("报文模版传参调用失败" + throwable.getMessage());
            }
        };
    }
}
