package com.zuidaima.util;

import java.io.File;
import java.io.IOException;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.setting.Setting;

public class PropsUtil {
	public static Setting props = new Setting("config.setting");
//	public static Setting props = new Setting(getPath() + "/config.setting");

	public static final String IS_OPEN_COPY = "openCopy";
	public static final String NEW_DIRS = "dirs";

	public static final String IS_RENAME = "reName";
	public static final String FILE_SUFFIX = "nameSuffix";

	public static final String IS_UPLOAD = "isUpload";
	public static final String FTP_HOST = "ftpUploadAddr";
	public static final String FTP_PORT = "ftpPort";
	public static final String FTP_USER = "ftpUserName";
	public static final String FTP_PASS = "ftpPassword";
	public static final String FTP_PATH = "ftpPath";
	public static final String CHART_SET = "chartSet";
	public static final String MONITOR_DIR = "monitorDir";
	public static final String SECOND = "second";

	public static final Integer defaultFtpPort = 21;
	public static final String verticalLine = "|";

	public static Setting getVal() {
		return props;
	}

	public static String getPath(){
		File directory = new File("");
		try {
			directory.getCanonicalPath();
		} catch (IOException e) {
			e.printStackTrace();
		}
		String path = directory.getAbsolutePath();

		return path;
	}

	public static boolean getBooleanValByProps(String key) {
		Object object = props.get(key);
		if (ObjectUtil.isEmpty(object)) {
			return false;
		}
		return Boolean.valueOf(object.toString()).booleanValue();
	}

	public static int getIntegerValByProps(String key) {
		Object object = props.get(key);
		if (ObjectUtil.isEmpty(object)) {
			return defaultFtpPort;
		}
		return Integer.valueOf(object.toString());
	}

	public static String getUserName() {
		return props.get(FTP_USER) + "";
	}

	public static String getPassword() {
		return props.get(FTP_PASS) + "";
	}

	public static Integer getPort() {
		return getIntegerValByProps(FTP_PORT);
	}

	public static String getBasePath() {
		return props.get(FTP_PATH) + "";
	}

	public static String getChartSet() {
		return props.get(CHART_SET) + "";
	}

	public static boolean isCopy() {
		return getBooleanValByProps(IS_OPEN_COPY);
	}

	public static boolean isUpload() {
		return getBooleanValByProps(IS_UPLOAD);
	}

	public static boolean isReName() {
		return getBooleanValByProps(IS_RENAME);
	}
}
最近下载更多
7482166  LV1 2022年12月9日
zw050256  LV7 2022年9月30日
decine  LV1 2022年8月3日
笨小孩一号  LV22 2022年8月2日
crosa_Don  LV18 2022年7月6日
唯一&Mike  LV3 2022年5月1日
xiex909  LV27 2022年3月31日
q13246932  LV1 2022年3月28日
微信网友_5859249697001472  LV1 2022年3月5日
微信网友_5836744970964992  LV1 2022年2月17日
最近浏览更多
操作者 4月10日
暂无贡献等级
WBelong  LV7 3月29日
康日澜  LV9 2023年7月12日
iuchengli 2023年3月17日
暂无贡献等级
7482166  LV1 2022年12月9日
校园网  LV9 2022年11月4日
zw050256  LV7 2022年9月30日
decine  LV1 2022年8月2日
笨小孩一号  LV22 2022年8月2日
crosa_Don  LV18 2022年7月6日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友