package com.pj.api.client.level_two_server;

import com.pj.api.client.admin.AdminInterfaceFallback;
import com.pj.api.dto.PurchaserDto;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * @Author Mechrevo
 * @Date 2023 08 01 10 39
 **/
@Component
public class LevelTwoServerInterfaceFallback implements FallbackFactory<LevelTwoServerInterface> {

    private static final Logger log = LoggerFactory.getLogger(AdminInterfaceFallback.class);

    @Override
    public LevelTwoServerInterface create(Throwable throwable) {
        return new LevelTwoServerInterface() {
            @Override
            public PurchaserDto getByPurchaserId(Long id) {
                System.out.println(throwable.getMessage());
                log.error("国内商家信息查询错误:{},错误信息是{}",id,throwable.getMessage());
                return null;
            }

            @Override
            public boolean purchaserDto(PurchaserDto purchaserDto) {
                System.out.println(throwable.getMessage());
                log.error("国内商家信息添加错误:{},错误信息是{}",purchaserDto,throwable.getMessage());
                return false;
            }
        };
    }
}
