package ink.wgink.module.file.service.v2;

import ink.wgink.module.file.enums.UploadTypeEnum;
import ink.wgink.module.file.pojo.dtos.FileInfoDTO;
import ink.wgink.module.file.pojo.dtos.v2.FileUploadSuccessDTO;
import ink.wgink.module.file.pojo.vos.v2.FileSaveVO;
import ink.wgink.module.file.pojo.vos.v2.FileUpdateVO;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.pos.FilePO;
import ink.wgink.pojo.result.SuccessResultList;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.util.List;
import java.util.Map;

/**
 * @ClassName: IFileV2Service
 * @Description: 文件V2
 * @Author: wanggeng
 * @Date: 2022/4/13 16:15
 * @Version: 1.0
 */
public interface IFileService {

    String FILE_SUMMARY_LOCAL = "local";
    String FILE_SUMMARY_CENTER = "center";

    /**
     * 单文件上传
     *
     * @param uploadFile     上传文件
     * @param uploadTypeEnum 上传类型
     * @return
     */
    FileUploadSuccessDTO uploadSingle(MultipartFile uploadFile, UploadTypeEnum uploadTypeEnum);

    /**
     * 单文件上传
     *
     * @param inputStream    文件流
     * @param uploadTypeEnum 上传类型
     * @param fileName       带后缀的文件名
     * @return
     */
    FileUploadSuccessDTO uploadSingle(InputStream inputStream, UploadTypeEnum uploadTypeEnum, String fileName);

    /**
     * 单文件上传
     *
     * @param token          token
     * @param uploadFile     上传文件
     * @param uploadTypeEnum 上传类型
     * @return
     */
    FileUploadSuccessDTO uploadSingleByToken(String token, MultipartFile uploadFile, UploadTypeEnum uploadTypeEnum);

    /**
     * 单文件上传
     *
     * @param token
     * @param inputStream
     * @param uploadTypeEnum
     * @param fileName
     * @return
     */
    FileUploadSuccessDTO uploadSingleByToken(String token, InputStream inputStream, UploadTypeEnum uploadTypeEnum, String fileName);

    /**
     * 单文件上传
     *
     * @param userId         用户ID
     * @param uploadFile     上传文件
     * @param uploadTypeEnum 上传类型
     * @return
     */
    FileUploadSuccessDTO uploadSingleByUserId(String userId, MultipartFile uploadFile, UploadTypeEnum uploadTypeEnum);


    /**
     * 单文件上传
     *
     * @param userId
     * @param inputStream
     * @param uploadTypeEnum
     * @param fileName
     * @return
     */
    FileUploadSuccessDTO uploadSingleByUserId(String userId, InputStream inputStream, UploadTypeEnum uploadTypeEnum, String fileName);

    /**
     * 保存文件
     *
     * @param fileSaveVO
     * @return
     */
    FileUploadSuccessDTO saveFile(FileSaveVO fileSaveVO);

    /**
     * 修改文件VO
     *
     * @param fileUpdateVO
     */
    void update(FileUpdateVO fileUpdateVO);

    /**
     * 删除文件
     *
     * @param fileIds
     */
    void delete(List<String> fileIds);

    /**
     * 获取文件
     *
     * @param params
     * @return
     */
    FilePO getPO(Map<String, Object> params);

    /**
     * 获取文件
     *
     * @param fileId
     * @return
     */
    FilePO getPO(String fileId);

    /**
     * 重定向下载
     *
     * @param request
     * @param response
     * @param isOpen   是否打开
     * @param fileId   文件ID
     */
    void downloadRedirect(HttpServletRequest request, HttpServletResponse response, boolean isOpen, String fileId);

    /**
     * 下载
     *
     * @param request
     * @param response
     * @param fileId
     */
    void download(HttpServletRequest request, HttpServletResponse response, String fileId);


    /**
     * 文件列表
     *
     * @param params
     * @return
     */
    List<FileInfoDTO> list(Map<String, Object> params);

    /**
     * 文件分页列表
     *
     * @param page
     * @return
     */
    SuccessResultList<List<FileInfoDTO>> listPage(ListPage page);

    /**
     * 获取文件保存VO
     *
     * @param inputStream
     * @param uploadTypeEnum
     * @param fileName
     * @return
     */
    FileSaveVO getCenterFileSaveVO(InputStream inputStream, UploadTypeEnum uploadTypeEnum, String fileName, String creator);

}
