package com.hdkj.lt.feign.fallback;

import com.hdkj.lt.feign.IRefreshCacheApiClient;
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/7/10 20:48
 * @Version 1.0
 */
@Slf4j
@Component
public class RefreshCacheApiClientFallBack implements FallbackFactory<IRefreshCacheApiClient> {
    @Override
    public IRefreshCacheApiClient create(Throwable cause) {
        return new IRefreshCacheApiClient() {
            @Override
            public ApiResponse<Void> refreshFeederCacheById(String feederId) {
                return ApiResponse.fail(String.format("刷新缓存【%s】-refreshAllFeederCache 远程调用服务异常：%s", feederId, cause.getMessage()));
            }

            @Override
            public ApiResponse<Void> generateCartoonData(Long objId, String objType) {
                return ApiResponse.fail(String.format("生成动画反演数据 远程调用服务异常：%s", cause.getMessage()));
            }
        };
    }
}
