package com.bonus.system.api;

import com.bonus.common.core.constant.SecurityConstants;
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 R<SysFile> upload(@RequestPart(value = "file") MultipartFile file);

    /**
     * 获取图片的base64地址
     *
     * @param fileId
     * @param source
     * @return R<SysFile>
     * @description
     * @author cwchen
     * @date 2024/3/21 15:24
     */
    @PostMapping(value = "/mongoFile/getImgBase64")
    public R<SysFile> getImgBase64(@RequestBody String fileId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    /**
     * 获取图片的base64地址
     *
     * @param fileId
     * @param source
     * @return R<SysFile>
     * @description
     * @author cwchen
     * @date 2024/3/21 15:24
     */
    @PostMapping(value = "/mongoFile/getFileBast64")
    public R<SysFile> getFileBast64(@RequestBody String fileId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 返回字节
     *
     * @param fileId
     * @param source
     * @return
     */
    @PostMapping(value = "/mongoFile/getFileByte")
    public R<byte[]> getFileByte(@RequestBody String fileId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    /**
     * 单个文件上传
     *
     * @param file
     * @param source
     * @return AjaxR
     * @description
     * @author cwchen
     * @date 2024/3/21 17:25
     */
    @PostMapping(value = "/mongoFile/singleUploadFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public R singleUploadFile(@RequestPart(value = "file") MultipartFile file, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 多个文件上传
     *
     * @param files
     * @param source
     * @return AjaxR
     * @description
     * @author cwchen
     * @date 2024/3/21 17:25
     */
    @PostMapping(value = "/mongoFile/mostUploadFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public R mostUploadFile(@RequestPart(value = "files") MultipartFile[] files, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 删除文件
     *
     * @param fileId
     * @param source
     * @return AjaxR
     * @description
     * @author cwchen
     * @date 2024/3/21 17:27
     */
    @PostMapping(value = "/mongoFile/delFile")
    public R delFile(@RequestBody String fileId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * base64文件上传
     * @param base64
     * @param source
     * @return R
     * @author cwchen
     * @date 2024/6/11 10:22
     */
    @PostMapping(value = "/mongoFile/uploadFileByBase64", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public R uploadFileByBase64(@RequestPart(value = "base64") String base64, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

}
