package com.gyee.frame.model.config;

import org.springframework.boot.system.ApplicationHome;

import java.io.File;

public class FilePathConfig {
    private static String filePath;
    private static String dataPath;

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

    public static String getDataPath() {
        if(dataPath==null){
            getFilePath();
            //dataPath = filePath.substring(0, filePath.lastIndexOf("\\"));
            dataPath = filePath+"\\data";
            File file = new File(dataPath + "\\光伏逆变器负荷率利用小时计算");
            if(!file.exists()) file.mkdirs();
        }
        return dataPath;
    }
}
