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

import ink.wgink.module.file.pojo.dtos.filedownload.FileDownloadDTO;
import ink.wgink.module.file.pojo.vos.filedownload.FileDownloadVO;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.pos.FilePO;
import ink.wgink.pojo.result.SuccessResultList;

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

/**
 * @ClassName: IFileDownloadService
 * @Description: 文件下载
 * @Author: wanggeng
 * @Date: 2022/8/2 09:58
 * @Version: 1.0
 */
public interface IFileDownloadService {

    /**
     * 新增下载记录
     *
     * @param fileDownloadVO
     */
    void save(FileDownloadVO fileDownloadVO);

    /**
     * 下载列表
     *
     * @param params
     * @return
     */
    List<FileDownloadDTO> list(Map<String, Object> params);

    /**
     * 下载列表
     *
     * @param fileId
     * @return
     */
    List<FileDownloadDTO> listByFileId(String fileId);

    /**
     * 下载分页列表
     *
     * @param page
     * @return
     */
    SuccessResultList<List<FileDownloadDTO>> listPage(ListPage page);

    /**
     * 下载分页列表
     *
     * @param fileId
     * @param page
     * @return
     */
    SuccessResultList<List<FileDownloadDTO>> listPageByFileId(String fileId, ListPage page);


    /**
     * 统计下载列表
     *
     * @param fileId
     * @return
     */
    Integer countByFileId(String fileId);

    /**
     * 文件下载
     *
     * @param request
     * @param response
     * @param filePO
     */
    void download(HttpServletRequest request, HttpServletResponse response, FilePO filePO);

    /**
     * 文件重定向下载
     *
     * @param request
     * @param response
     * @param isOpen
     * @param filePO
     */
    void downloadRedirect(HttpServletRequest request, HttpServletResponse response, boolean isOpen, FilePO filePO);

}
