package com.css.simulation.resource.server.infra.feign.service;

import api.common.pojo.common.ResponseBodyVO;
import api.common.pojo.param.MinioParameter;
import com.css.simulation.resource.server.infra.feign.config.FeignConfiguration;
import com.css.simulation.resource.server.infra.feign.fallback.FileDownServiceFallback;
import feign.Response;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;


//@FeignClient(name = "test2", url = "http://47.94.105.148",path = "/simulation/resource/common", fallback = FileDownServiceFallback.class, configuration = FeignConfiguration.class)
@FeignClient(
        contextId = "file",
        value = "simulation-resource-common",
        path = "/simulation/resource/common",
        fallback = FileDownServiceFallback.class,
        configuration = FeignConfiguration.class
)
public interface FileDownService {

    @PostMapping(value = "/minio/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    ResponseBodyVO<String> upload(@RequestPart("file") MultipartFile file,
                                  @RequestParam("objectName") String objectName);

    @GetMapping(value = "/minio/getPublicUrl")
    ResponseBodyVO<String> getPublicUrl(@RequestParam("objectName") String objectName);

    @GetMapping(value = "/minio/uploadLocalFile")
    ResponseBodyVO<String> uploadLocalFile(@RequestParam("localFilePath") String localFilePath,
                                           @RequestParam("objectName") String objectName);

    @GetMapping(value = "/minio/copy")
    ResponseBodyVO<String> copy(
            @RequestParam("source") String source,
            @RequestParam("target") String target//  "/xx/xxx/x/xx"
    );

    @GetMapping(value = "/minio/move")
    ResponseBodyVO<String> move(
            @RequestParam("source") String source,
            @RequestParam("target") String target//  "/xx/xxx/x/xx"
    );

    @PostMapping(value = "/minio/uploadProcessBar", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    ResponseBodyVO<String> uploadProcessBar(@RequestPart("file") MultipartFile file,
                                            @RequestParam("objectName") String objectName,
                                            @RequestParam("objectPath") String objectPath);

    @PostMapping("/minio/download")
    Response download(@RequestBody @Validated MinioParameter minioParameter);

    @PostMapping("/minio/list")
    ResponseBodyVO<List<String>> list(@RequestBody @Validated MinioParameter minioParameter);

    @PostMapping("/minio/listDeepOne")
    ResponseBodyVO<List<String>> listDeepOne(@RequestBody @Validated MinioParameter minioParameter);

    @RequestMapping("/minio/getPreviewUrl")
    ResponseBodyVO<String> getPreviewUrl(@RequestBody @Validated MinioParameter minioParameter);

    @PostMapping("/minio/remove")
    Response remove(@RequestBody @Validated MinioParameter minioParameter);

}
