package cn.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 文件路径 示例（ Windows配置D:/mooding/uploadPath，Linux配置 /home/mooding/uploadPath）
 * 
 * 读取配置文件env.properties中信息
 *   一级目录：reposityDB、reposityLog、reposityURI
 *   默认二级目录为：
 *   1）数据库表备份与恢复文件：dbbackup(reposityDB)
 *   2）运行时日志文件：log(reposityLog)
 *   3）临时目录temp
 *   4）归档文件：archive
 *   5）页面上传的各种文档document
 *   6）系统授权 auth
 *   7）页面上传的各种图片image
 *   8）页面上传头像路径avatar
 *   9）页面上传各种签字signature
 *  10）模板文件 template
 *  11）缓存 cache
 */
@Component
/**读取application.yml中项目相关配置信息*/
@ConfigurationProperties(prefix = "sam.sys")
public class SysConfig 
{
	/** 版本 */
	private String version;
	/** 版权年份 */
	private String copyrightYear;
	/** 验证码类型 math 数组计算 char 字符验证*/
	private String captchaType;
	
	//存放日志信息的路径
	private String reposityLog;
	//存放日志之外的其他文档的路径及相关定义
	private String reposityURI;
	//RequestUrlAspect输出到监控平台
	private String debug;

	/** 获取地址开关 */
	private static boolean addressEnabled;
	/**@Log写库操作是否开启 */
	private static boolean aspectLog;

	private static boolean unifyFields;
	/**约定：
	 * 库表结构名用下划线；页面上组件名可以是下划线
	 * 或
	 * 驼峰表示法  此情况 需要开启驼峰转换
	 */
    private static boolean humpConversion;
	/**
	 * 日志路径
	 */
	public String getLogPath()
	{
		return getReposityLog() + "log/";
	}

	/**
	 * 获取头像上传路径
	 */
	public String getAvatarPath()
	{
		return getReposityURI() + "avatar";
	}

	public String getAuthPath()
	{
		return getReposityURI() + "auth/";
	}
	public String getTempPath()
	{
		return getReposityURI() + "temp/";
	}
	public static boolean isAddressEnabled() {
		return addressEnabled;
	}
	public void setAddressEnabled(boolean addressEnabled) {
		SysConfig.addressEnabled = addressEnabled;
	}

	public String getCopyrightYear() {
		return copyrightYear;
	}

	public String getVersion() {
		return version;
	}
	public void setVersion(String version) {
		this.version = version;
	}
	public void setCopyrightYear(String copyrightYear) {
		this.copyrightYear = copyrightYear;
	}

	public String getCaptchaType() {
		return captchaType;
	}
	/**
	 * @return the aspectLog
	 */
	public boolean isAspectLog() {
		return aspectLog;
	}
	/**
	 * @param aspectLog the aspectLog to set
	 */
	public void setAspectLog(boolean aspectLog) {
		SysConfig.aspectLog = aspectLog;
	}
	
	public String getReposityLog() {
		return reposityLog;
	}
	public void setReposityLog(String reposityLog) {
		this.reposityLog = reposityLog;
	}
	public String getReposityURI() {
		return reposityURI;
	}
	public void setReposityURI(String reposityURI) {
		this.reposityURI = reposityURI;
	}
	public String getDebug() {
		return debug;
	}
	public void setDebug(String debug) {
		this.debug = debug;
	}
	/**
	 * @param captchaType the captchaType to set
	 */
	public void setCaptchaType(String captchaType) {
		this.captchaType = captchaType;
	}
	
	public boolean isHumpConversion() {
		return humpConversion;
	}
	public void setHumpConversion(boolean humpConversion) {
		SysConfig.humpConversion = humpConversion;
	}
	/**
	 * @return the unifyFields
	 */
	public boolean isUnifyFields() {
		return unifyFields;
	}
	/**
	 * @param unifyFields the unifyFields to set
	 */
	public void setUnifyFields(boolean unifyFields) {
		SysConfig.unifyFields = unifyFields;
	}

}
