package com.bonus.system.api;

import com.bonus.common.core.web.domain.AjaxResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import com.bonus.common.core.constant.ServiceNameConstants;
import com.bonus.common.core.domain.R;
import com.bonus.system.api.domain.SysFile;
import com.bonus.system.api.factory.RemoteFileFallbackFactory;

/**
 * 文件服务
 * 
 * @author bonus
 */
@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 AjaxResult upload(@RequestPart(value = "file") MultipartFile file);

    /**
     * 多文件上传
     * @param files 多个文件流
     * @return 文件信息
     */
    @PostMapping(value = "/uploadFiles", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public AjaxResult uploadFile(@RequestPart(value = "files") MultipartFile[] files);

    /**
     * 文件删除
     * 从各个存储平台删除文件
     * @param objectKey * @param objectKey，除mongodb 存fileid之外，其他均存上传文件的网络路径
     * @return 成功或失败信息
     */
    @PostMapping("/deleteFile")
    public AjaxResult deleteFile(@RequestParam("objectKey") String objectKey);

    @GetMapping("/getFullFileUrl")
    public String getFullFileUrl(@RequestParam("fileUrl") String fileUrl);
}
