package com.qunzhixinxi.hnqz.admin.util;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

/**
 * {@code OsEnvUtils} 系统环境工具类
 *
 * @author Hengchen.Sun
 * @version 1.0.0
 * @date 2021-04-16
 * @since ver.1.0.0
 */
public final class OsEnvUtils {

	private OsEnvUtils(){}

	/**
	 * 获取系统名称
	 * @return 系统名称
	 */
	public static String getOSName(){
		Properties props = System.getProperties(); // 获得系统属性集
		String osName = props.getProperty("os.name").toLowerCase(); // 操作系统名称
		return osName;
	}

	/**
	 * 根据环境获取不用的路径
	 *
	 * @return 路径map
	 */
	public static Map<String, Object> getEachEnvPaths() {
		String osName = getOSName();
		Map<String, Object> pathMap = new HashMap<String, Object>();
		if (osName.contains("linux") || osName.contains("unix")) {
			pathMap.put("EXCEL_FILE_PATH","/excel/");
		}
		if (osName.contains("mac")) {
			pathMap.put("EXCEL_FILE_PATH","/Users/jimmy/Desktop/excel/");
		}
		if (osName.contains("windows")) {
			pathMap.put("EXCEL_FILE_PATH","D:\\");
		}
		return pathMap;
	}
}
