|
@@ -1,12 +1,8 @@
|
|
|
package cn.com.qmth.examcloud.web.config;
|
|
|
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
-import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
-import cn.com.qmth.examcloud.commons.util.PropertiesUtil;
|
|
|
-
|
|
|
/**
|
|
|
* 系统配置
|
|
|
*
|
|
@@ -15,45 +11,27 @@ import cn.com.qmth.examcloud.commons.util.PropertiesUtil;
|
|
|
* @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
|
|
|
*/
|
|
|
@Component
|
|
|
+@ConfigurationProperties("examcloud.web.sys")
|
|
|
public class SystemConfig {
|
|
|
|
|
|
- @Value("${$dir}")
|
|
|
- private String dir;
|
|
|
-
|
|
|
- @Value("${$tempDir}")
|
|
|
- private String tempDir;
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取数据目录
|
|
|
- *
|
|
|
- * @author WANGWEI
|
|
|
- * @return
|
|
|
- */
|
|
|
- public static String getDataDir() {
|
|
|
- String dir = PropertiesUtil.getString("$dir");
|
|
|
- if (StringUtils.isBlank(dir)) {
|
|
|
- throw new StatusException("370", "数据目录未配置");
|
|
|
- }
|
|
|
- if (dir.endsWith("/")) {
|
|
|
- dir = dir.substring(0, dir.length() - 1);
|
|
|
- }
|
|
|
- return dir;
|
|
|
+ private String dataDir;
|
|
|
+
|
|
|
+ private String tempDataDir;
|
|
|
+
|
|
|
+ public String getDataDir() {
|
|
|
+ return dataDir;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setDataDir(String dataDir) {
|
|
|
+ this.dataDir = dataDir;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getTempDataDir() {
|
|
|
+ return tempDataDir;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 获取临时数据目录
|
|
|
- *
|
|
|
- * @author WANGWEI
|
|
|
- * @return
|
|
|
- */
|
|
|
- public static String getTempDataDir() {
|
|
|
- String tempDir = PropertiesUtil.getString("$tempDir");
|
|
|
- if (StringUtils.isBlank(tempDir)) {
|
|
|
- throw new StatusException("370", "临时数据目录未配置");
|
|
|
- }
|
|
|
- if (tempDir.endsWith("/")) {
|
|
|
- tempDir = tempDir.substring(0, tempDir.length() - 1);
|
|
|
- }
|
|
|
- return tempDir;
|
|
|
+ public void setTempDataDir(String tempDataDir) {
|
|
|
+ this.tempDataDir = tempDataDir;
|
|
|
}
|
|
|
+
|
|
|
}
|