package com.yd.oss.feign.client;

import com.yd.common.result.Result;
import com.yd.oss.feign.fallback.ApiChunkedUploadContextFeignFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import java.util.Map;

/**
 * 分片上传上下文信息Feign客户端
 */
@FeignClient(name = "yd-oss-api",path = "/oss/api/chunkedUploadContext",fallbackFactory = ApiChunkedUploadContextFeignFallbackFactory.class)
public interface ApiChunkedUploadContextFeignClient {

    /**
     * 上传单个分片
     * @param taskId
     * @param chunkIndex
     * @param chunk
     * @param projectBizId
     * @param source
     * @return
     */
    @PostMapping("/uploadChunk")
    Result<Void> uploadChunk(@RequestParam(value = "taskId",required = false) String taskId,
                             @RequestParam(value = "chunkIndex",required = false) Integer chunkIndex,
                             @RequestParam(value = "chunk",required = false) MultipartFile chunk,
                             @RequestParam(value = "projectBizId",required = false) String projectBizId,
                             @RequestParam(value = "source",required = false) String source);

    /**
     * 完成分片上传（合并）
     * @param taskId
     * @param projectBizId
     * @return
     */
    @PostMapping("/finishChunks")
    Result<Map<String, Object>> finishChunks(@RequestParam(value = "taskId",required = false) String taskId,
                                             @RequestParam(value = "projectBizId",required = false) String projectBizId);
}
