package com.gyee.wisdom.dataadapter.configuration;

import org.springframework.boot.system.ApplicationHome;
import org.springframework.stereotype.Component;

import java.io.File;

@Component
public class FilePathConfig {
    private static String filePath;
    private static String excelPath;

    public static String getFilePath() {
        if(filePath==null){
            ApplicationHome home = new ApplicationHome(FilePathConfig.class);
            filePath=home.getSource().getParentFile().getAbsolutePath();
        }
        return filePath;
    }

    public static String getExcelPath() {
        if(excelPath==null){
            getFilePath();
            excelPath = filePath+"\\excel\\";
            File file = new File(excelPath);
            if(!file.exists()) file.mkdirs();
        }
        return excelPath;
    }
}
