package com.qingyun.common.config;

import lombok.Data;
import lombok.Getter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 读取项目相关配置
 *
 * @author jianlu
 */

@Data
@Component
@ConfigurationProperties(prefix = "qingyun")
public class QingYunConfig {

    /**
     * 项目名称
     */
    private String name;

    /**
     * 版本
     */
    private String version;

    /**
     * 版权年份
     */
    private String copyrightYear;

    /**
     * 缓存懒加载
     */
    private boolean cacheLazy;

    /**
     * 获取地址开关
     */
    @Getter
    private static boolean addressEnabled;
    /**
     * 默认上传地址
     */
    private static String profile;

    /**项目网址*/
    private static   String projectUrl;

    public void setAddressEnabled(boolean addressEnabled) {
        QingYunConfig.addressEnabled = addressEnabled;
    }

    public static String getProfile(){
        return profile;
    }

    public void setProfile(String profile) {
        QingYunConfig.profile = profile;
    }

    public void setProjectUrl(String projectUrl) {
        QingYunConfig.projectUrl = projectUrl;
    }

    public static String getProjectUrl(){
        return projectUrl;
    }

    /**
     * 获取上传路径
     */
    public static String getUploadPath()
    {
        return getProfile() + "/upload";
    }

}
