package tech.easyflow.datacenter.excel.service;

import org.springframework.web.multipart.MultipartFile;
import tech.easyflow.common.entity.LoginAccount;
import tech.easyflow.datacenter.excel.model.DatacenterExcelDeriveRequest;
import tech.easyflow.datacenter.excel.model.DatacenterExcelExportRequest;
import tech.easyflow.datacenter.excel.model.DatacenterExcelMergeRequest;
import tech.easyflow.datacenter.excel.model.DatacenterExcelSplitRequest;
import tech.easyflow.datacenter.meta.entity.DatacenterImportJob;

import java.math.BigInteger;
import java.util.List;

public interface DatacenterExcelImportService {
    /**
     * 导入 Excel 工作簿并创建对应的数据源、目录和物化表。
     *
     * @param file Excel 工作簿文件
     * @param sourceName 用户指定的数据源名称，留空时使用文件名
     * @param account 当前登录账号
     * @return 已完成的导入任务
     * @throws Exception 文件读取或数据写入失败时抛出
     */
    DatacenterImportJob importWorkbook(MultipartFile file, String sourceName, LoginAccount account) throws Exception;

    DatacenterImportJob splitWorkbook(DatacenterExcelSplitRequest request, LoginAccount account);

    DatacenterImportJob mergeWorkbook(DatacenterExcelMergeRequest request, LoginAccount account);

    DatacenterImportJob deriveWorkbook(DatacenterExcelDeriveRequest request, LoginAccount account);

    DatacenterImportJob exportWorkbook(DatacenterExcelExportRequest request, LoginAccount account) throws Exception;

    DatacenterImportJob getImportJobDetail(BigInteger jobId);

    List<DatacenterImportJob> listJobs(BigInteger sourceId, BigInteger tableId);
}
