From d2213e56167dcd77c967e996df7c73e104f019d1 Mon Sep 17 00:00:00 2001
From: 935090232@qq.com <ak473600000>
Date: Mon, 21 Feb 2022 23:40:08 +0800
Subject: [PATCH] fead:百度编辑器配置文件改造

---
 zq-erp/src/main/java/com/matrix/component/ueditor/ConfigManager.java |   36 +++++++++++++++++++-----------------
 1 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/zq-erp/src/main/java/com/matrix/component/ueditor/ConfigManager.java b/zq-erp/src/main/java/com/matrix/component/ueditor/ConfigManager.java
index 689920b..b258795 100644
--- a/zq-erp/src/main/java/com/matrix/component/ueditor/ConfigManager.java
+++ b/zq-erp/src/main/java/com/matrix/component/ueditor/ConfigManager.java
@@ -10,14 +10,15 @@
 import java.net.URISyntaxException;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.ResourceBundle;
 
+import com.alibaba.fastjson.JSON;
+import com.matrix.component.tools.JSONUtil;
 import com.matrix.component.ueditor.define.ActionMap;
+import com.matrix.core.tools.EnvironmentHolder;
+import com.matrix.system.common.constance.PropertiesConstance;
 import org.apache.commons.io.IOUtils;
 import org.json.JSONArray;
 import org.json.JSONObject;
-import org.springframework.context.EnvironmentAware;
-import org.springframework.core.env.Environment;
 
 
 /**
@@ -26,9 +27,8 @@
  * @author hancong03@baidu.com
  *
  */
-public final class ConfigManager implements EnvironmentAware {
+public final class ConfigManager {
 
-	private Environment env;
 	private final String rootPath;
 	private final String originalPath;
 	private final String contextPath;
@@ -40,22 +40,17 @@
 	// 远程图片抓取filename定义
 	private final static String REMOTE_FILE_NAME = "remote";
 
-	private final static String FILES_TORAGE_PATH ="file_storage_path";
-
-	@Override
-	public void setEnvironment(Environment environment) {
-		env = environment;
 
 
-	}
+	private UeditorProperties ueditorProperties = null;
 
 	/*
 	 * 通过一个给定的路径构建一个配置管理器, 该管理器要求地址路径所在目录下必须存在config.properties文件
 	 */
-	private ConfigManager(String rootPath, String contextPath, String uri) throws FileNotFoundException, IOException {
+	private ConfigManager(String rootPath, String contextPath, String uri, UeditorProperties ueditorProperties ) throws FileNotFoundException, IOException {
 
 		rootPath = rootPath.replace("\\", "/");
-
+		this.ueditorProperties=ueditorProperties;
 		this.rootPath = rootPath;
 		this.contextPath = contextPath;
 		if (contextPath.length() > 0) {
@@ -76,12 +71,13 @@
 	 *            服务器所在项目路径
 	 * @param uri
 	 *            当前访问的uri
+	 * @param ueditorProperties
 	 * @return 配置管理器实例或者null
 	 */
-	public static ConfigManager getInstance(String rootPath, String contextPath, String uri) {
+	public static ConfigManager getInstance(String rootPath, String contextPath, String uri, UeditorProperties ueditorProperties) {
 
 		try {
-			return new ConfigManager(rootPath, contextPath, uri);
+			return new ConfigManager(rootPath, contextPath, uri,ueditorProperties);
 		} catch (Exception e) {
 			return null;
 		}
@@ -162,7 +158,7 @@
 
 		conf.put("savePath", savePath);
 
-		String fileStoragePath = env.getProperty(FILES_TORAGE_PATH);
+		String fileStoragePath = EnvironmentHolder.getPropertis(PropertiesConstance.FILE_STORAGE_PATH);
 		conf.put("rootPath",fileStoragePath);
 
 		return conf;
@@ -181,8 +177,14 @@
 		//String configContent = this.readFile(this.getConfigPath());
 		String configContent = this.filter(IOUtils.toString(this.getClass().getClassLoader().getResourceAsStream("config/config.json")));
 
+
 		try {
-			JSONObject jsonConfig = new JSONObject(configContent);
+
+			com.alibaba.fastjson.JSONObject extend = JSONUtil.extend(
+					JSON.parseObject(configContent),
+					JSON.parseObject(JSON.toJSONString(ueditorProperties)));
+			jsonConfig=new JSONObject(extend.toJSONString());
+
 			this.jsonConfig = jsonConfig;
 		} catch (Exception e) {
 			this.jsonConfig = null;

--
Gitblit v1.9.1