package com.zhangmeng.api.service.file;

import com.zhangmeng.model.entity.FileInfo;
import com.zhangmeng.model.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.Map;

@Api(tags = "文件上传")
public interface UploadControllerApi {

    @ApiOperation("文件上传-文件流")
    public Result upload(MultipartFile file, FileInfo.UploadType type);

    @ApiOperation("文件上传-base64")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "文件上传的类型", required = false),
            @ApiImplicitParam(name = "base64", value = "base64 字符", required = true)
    })
    public Result upload(FileInfo.UploadType type, String base64);


    /**
     * fastDfs 文件下载
     * @param groupName 组名 group1
     * @param remoteFileNam 远程文件名 M00/00/00/wKg0pWEkVIyACp5-AALQU0eeiTo865.jpg
     * @param response
     * @return
     */
    @ApiOperation("文件下载")
    public Result download(String groupName, String remoteFileNam, HttpServletResponse response);


    /**
     * {
     * success : 0 | 1,           // 0 表示上传失败，1 表示上传成功
     * message : "提示的信息，上传成功或上传失败及错误信息等。",
     * url     : "图片地址"        // 上传成功时才返回
     * }
     *
     * @return
     */
    @ApiOperation("md编辑器上传")
    public Map<String, Object> md(@RequestParam(value = "editormd-image-file", required = false) MultipartFile file);
}
