package com.qmth.sop.business.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.qmth.sop.business.bean.dto.AttachmentInfoDto;
import com.qmth.sop.business.entity.BasicAttachment;
import com.qmth.sop.common.enums.UploadFileEnum;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.List;

/**
 * <p>
 * 所有附件记录表 服务类
 * </p>
 *
 * @author wangliang
 * @since 2023-07-17
 */
public interface BasicAttachmentService extends IService<BasicAttachment> {

    /**
     * 验证附件
     *
     * @param file
     * @return
     * @throws IOException
     */
    public AttachmentInfoDto validateAttachment(File file) throws IOException;

    /**
     * 验证附件
     *
     * @param file
     * @return
     * @throws IOException
     */
    public AttachmentInfoDto validateAttachment(MultipartFile file) throws IOException;

    /**
     * 上传文件接口
     *
     * @param file
     * @param type
     * @return
     * @throws IOException
     */
    public BasicAttachment saveAttachment(File file, UploadFileEnum type) throws Exception;

    /**
     * 上传文件接口
     *
     * @param file
     * @param type
     * @param key
     * @return
     * @throws IOException
     */
    public BasicAttachment saveAttachment(MultipartFile file, UploadFileEnum type, String key) throws Exception;

    /**
     * 上传文件接口
     *
     * @param file
     * @param type
     * @param key
     * @return
     * @throws Exception
     */
    public BasicAttachment saveAttachmentNoAuth(MultipartFile file, UploadFileEnum type, String key) throws Exception;

    /**
     * 删除附件
     *
     * @param basicAttachment
     */
    public void deleteAttachment(BasicAttachment basicAttachment) throws Exception;

    /**
     * 文件预览
     *
     * @param path
     * @return
     */
    public String filePreview(String path) throws Exception;

    /**
     * 文件预览
     *
     * @param key
     * @return
     */
    public List<BasicAttachment> filePreviewApp(String key) throws Exception;

    /**
     * 文件预览
     *
     * @param attachmentId
     * @return
     */
    public String filePreview(Long attachmentId) throws Exception;

    /**
     * 文件预览
     *
     * @param basicAttachment
     * @return
     */
    public String filePreview(BasicAttachment basicAttachment) throws Exception;

    /**
     * 文件预览
     *
     * @param filePath
     * @return
     */
    public String filePreviewPath(String filePath) throws Exception;
}
