package com.inkasso.factoring.file.service;


import com.inkasso.adapter.enums.FileBusinessInterface;
import com.inkasso.adapter.exception.BusinessException;
import com.inkasso.adapter.service.KafubaoService;
import com.inkasso.adapter.util.CodeUtil;
import com.inkasso.factoring.file.entity.FileStorageDO;
import com.inkasso.factoring.file.enums.FileTypeEnum;
import com.inkasso.factoring.file.model.dto.FileStorageDTO;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.http.ResponseEntity;

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

public interface FileService extends KafubaoService<FileStorageDO, FileStorageDTO> {

    FileStorageDO uploadFile(HttpServletRequest request, FileBusinessInterface fileBusinessEnum);

    FileStorageDO uploadFile(MultipartFile multipartFile, FileBusinessInterface fileBusinessEnum);

    List<FileStorageDO> uploadFiles(HttpServletRequest request, List<FileBusinessInterface> list);

    List<FileStorageDO> findByBusinessId(Long businessId, String businessType);

    FileStorageDO findOneByBusinessId(Long businessId, String businessType);

    void updateBusinessId(List<Long> fileIds, Long businessId);

    void updateBusinessId(Long fileId, Long businessId);

    /**
     * 该接口 只能删除 图片上传人 和  操作人 一致的 数据
     * @param id
     */
    void delete(Long id);

    /**
     * 通过Url下载 采购合同文件、出征文件 并存储
     *
     * @param contractId
     * @param fileType
     * @param downUrl
     * @return
     */
    FileStorageDO addFileStorageWithBelongAndName(String contractId, FileTypeEnum fileType, String downUrl);

    /**
     * 通过Url下载 采购合同文件、出征文件、授权书 并存储
     *
     * @param transactionId
     * @param contractId
     * @param fileType
     * @param downUrl
     * @return
     */
    FileStorageDO addFileStorageWithBelongAndName(String contractId, String transactionId, FileTypeEnum fileType, String downUrl);


    ResponseEntity<Object> downloadFile(Long id);

    void downloadZipFile(List<FileStorageDO> settlementAllFiles, String desc, FileTypeEnum settlementZipFile, HttpServletResponse response);

    void renameFileStorageList(List<FileStorageDO> settlementAllFiles);

    void downloadPdfFile(HttpServletResponse response, File file);
}
