/**
 * BladeX Commercial License Agreement
 * Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
 * <p>
 * Use of this software is governed by the Commercial License Agreement
 * obtained after purchasing a license from BladeX.
 * <p>
 * 1. This software is for development use only under a valid license
 * from BladeX.
 * <p>
 * 2. Redistribution of this software's source code to any third party
 * without a commercial license is strictly prohibited.
 * <p>
 * 3. Licensees may copyright their own code but cannot use segments
 * from this software for such purposes. Copyright of this software
 * remains with BladeX.
 * <p>
 * Using this software signifies agreement to this License, and the software
 * must not be used for illegal purposes.
 * <p>
 * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
 * not liable for any claims arising from secondary or illegal development.
 * <p>
 * Author: Chill Zhuang (bladejava@qq.com)
 */
package org.springblade.file.service;

import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.core.tool.api.R;
import org.springblade.file.pojo.entity.Attachment;
import org.springblade.file.pojo.vo.AttachmentDetailVO;
import org.springblade.file.pojo.vo.FileVO;
import org.springframework.web.multipart.MultipartFile;

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

/**
 * 服务类
 *
 * @author zhaowei
 */
public interface IAttachmentService extends IService<Attachment> {

    /**
     * 批量上传
     *
     * @param files
     * @param fileName 文件名，如果 files只有1个，且fileName不为空，设置文件名为 fileName
     * @return
     */
    R<List<Attachment>> batchOssUpload(MultipartFile[] files, String fileName);

    /**
     * 获取附件，多个附件id用逗号分割
     * @param id
     * @return List<Attachment>
     */
    List<Attachment> getAttachment(String id);

    /**
     * 批量上传解压缩文件并删除文件
     *
     * @param files
     * @param workDir 工作目录，取文件相对于工作目录的相对路径作为前缀
     * @return
     */
    List<Attachment> batchOssUploadUnzipFilesAndDelete(List<File> files, File workDir);

    /**
     *  新事务批量保存
     * @param list
     */
    void batchSaveWithNewTransaction(List<Attachment> list);

    /**
     *  获取附件详情
     * @param id
     * @return
     */
    AttachmentDetailVO getDetail(Long id);

    /**
     *  解压文件并上传
     * @param file
     * @return
     */
    List<Attachment> unzipAndUpload(FileVO file);
}
