package com.yd.oss.feign.fallback;

import com.yd.common.result.Result;
import com.yd.oss.feign.client.ApiChunkedUploadContextFeignClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
import java.util.Map;

/**
 * 分片上传上下文信息Feign降级处理
 */
@Slf4j
@Component
public class ApiChunkedUploadContextFeignFallbackFactory implements FallbackFactory<ApiChunkedUploadContextFeignClient> {
    @Override
    public ApiChunkedUploadContextFeignClient create(Throwable cause) {
        return new ApiChunkedUploadContextFeignClient() {

            @Override
            public Result<Void> uploadChunk(MultipartFile chunk, String taskId, Integer chunkIndex, String projectBizId, String source) {
                return null;
            }

            @Override
            public Result<Map<String, Object>> finishChunks(String taskId, String projectBizId) {
                return null;
            }
        };
    }
}
