package com.djhk.common.api;

import com.djhk.common.api.domain.vo.FileVo;
import com.djhk.common.core.domain.R;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * 文件服务
 *
 * @author myk
 */
//@FeignClient(contextId = "remoteFileService", value = ServiceNameConstants.FILE_SERVICE, fallbackFactory = RemoteFileFallbackFactory.class)
public interface RemoteFileService
{
    /**
     * 上传文件
     *
     * @param file 文件信息
     * @return 结果
     */
    @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public R<FileVo> upload(@RequestPart(value = "file") MultipartFile file);

    /**
     * 上传文件
     *
     * @param file 文件信息
     * @return 结果
     */
    @PostMapping(value = "/minio/file", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public R<FileVo> file(@RequestPart(value = "file") MultipartFile file,@RequestParam("uavNum")String uavNum,@RequestParam("bucketName")String bucketName);

    @PostMapping(value = "/minio/v1/file", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public R<FileVo> fileV1(@RequestPart(value = "file") MultipartFile file,@RequestParam("objectPrefix")String objectPrefix,@RequestParam("bucketName")String bucketName,
                            @RequestParam("bizType")String bizType);

    /**
     * 文件下载
     * @return 结果
     */
    @RequestMapping(value = "/minio/file")
    public R<FileVo> download( @RequestParam("fileName") String fileName, @RequestParam("bucketName") String bucketName, @RequestParam("fileId") String fileId);

    /**
     * 查看文件 生成http地址
     * @return 结果
     */
    @GetMapping("/minio/preview/file")
    public R<String> getPreviewFile(@RequestParam("bucketName") String bucketName,
                                    @RequestParam("expires") Integer expires,
                                    @RequestParam("objectName") String objectName);

    @DeleteMapping(value = "/minio/file")
    public R deleteFile(@RequestParam("bucketName") String bucketName, @RequestParam("objectName") String objectName);


    @PostMapping(value = "/minio/v1/file", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public R<FileVo> fileV2(@RequestPart(value = "file") MultipartFile file,@RequestParam("objectPrefix")String objectPrefix,@RequestParam("bucketName")String bucketName,
                            @RequestParam("bizType")String bizType,@RequestParam("relateId") String relateId);

}
