package com.hdkj.lt.feign.fallback;

import com.hdkj.lt.feign.IApiTestClient;
import com.hdkj.hussar.ApiResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @Description
 * @Author wcx
 * @Date 2025/4/24 18:00
 * @Version 1.0
 */
@Slf4j
@Component
public class ApiTestFallBack implements FallbackFactory<IApiTestClient> {

    @Override
    public IApiTestClient create(Throwable cause) {
        return new IApiTestClient() {
            @Override
            public ApiResponse<String> sendMessage(String id) {
                log.error("request params: {}", id);
                return ApiResponse.fail(String.format("远程调用服务异常：%s", cause.getMessage()));
            }
        };
    }
}
