puzhibing
2022-08-22 1421f8e9c308c4741cb396309035009393b5b036
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package com.stylefeng.guns.config.properties;
 
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
 
import java.io.File;
 
import static com.stylefeng.guns.core.util.ToolUtil.getTempPath;
import static com.stylefeng.guns.core.util.ToolUtil.isEmpty;
 
/**
 * guns项目配置
 *
 * @author stylefeng
 * @Date 2017/5/23 22:31
 */
@Component
@ConfigurationProperties(prefix = GunsProperties.PREFIX)
public class GunsProperties {
 
    public static final String PREFIX = "guns";
 
    private Boolean kaptchaOpen = false;
 
    private Boolean swaggerOpen = false;
 
    // 文件上传位置配置
    private String fileUploadPath;
 
    // 文件服务器访问地址
    private String pictureServerAddress;
 
    private Boolean haveCreatePath = false;
 
    private Boolean springSessionOpen = false;
 
    /**
     * session 失效时间(默认为30分钟 单位:秒)
     */
    private Integer sessionInvalidateTime = 30 * 60;
 
    /**
     * session 验证失效时间(默认为15分钟 单位:秒)
     */
    private Integer sessionValidationInterval = 15 * 60;
    /**
     *前端接口调用基础路径
     */
    private String restUrl;
 
    public String getFileUploadPath() {
        //如果没有写文件上传路径,保存到临时目录
        if (isEmpty(fileUploadPath)) {
            return getTempPath();
        } else {
            //判断有没有结尾符,没有得加上
            if (!fileUploadPath.endsWith(File.separator)) {
                fileUploadPath = fileUploadPath + File.separator;
            }
            //判断目录存不存在,不存在得加上
            if (!haveCreatePath) {
                File file = new File(fileUploadPath);
                file.mkdirs();
                haveCreatePath = true;
            }
            return fileUploadPath;
        }
    }
 
    public void setFileUploadPath(String fileUploadPath) {
        this.fileUploadPath = fileUploadPath;
    }
 
    public String getPictureServerAddress() {
        return pictureServerAddress;
    }
 
    public void setPictureServerAddress(String pictureServerAddress) {
        this.pictureServerAddress = pictureServerAddress;
    }
 
    public Boolean getKaptchaOpen() {
        return kaptchaOpen;
    }
 
    public void setKaptchaOpen(Boolean kaptchaOpen) {
        this.kaptchaOpen = kaptchaOpen;
    }
 
    public Boolean getSwaggerOpen() {
        return swaggerOpen;
    }
 
    public void setSwaggerOpen(Boolean swaggerOpen) {
        this.swaggerOpen = swaggerOpen;
    }
 
    public Boolean getSpringSessionOpen() {
        return springSessionOpen;
    }
 
    public void setSpringSessionOpen(Boolean springSessionOpen) {
        this.springSessionOpen = springSessionOpen;
    }
 
    public Integer getSessionInvalidateTime() {
        return sessionInvalidateTime;
    }
 
    public void setSessionInvalidateTime(Integer sessionInvalidateTime) {
        this.sessionInvalidateTime = sessionInvalidateTime;
    }
 
    public Integer getSessionValidationInterval() {
        return sessionValidationInterval;
    }
 
    public void setSessionValidationInterval(Integer sessionValidationInterval) {
        this.sessionValidationInterval = sessionValidationInterval;
    }
 
    public String getRestUrl() {
        return restUrl;
    }
 
    public void setRestUrl(String restUrl) {
        this.restUrl = restUrl;
    }
}