提交 837c4b7e 编写于 作者: Z zhourui

增加web.json配置

上级 96bdd4df
......@@ -40,7 +40,6 @@ import com.x.base.core.project.config.Qiyeweixin;
import com.x.base.core.project.config.Query;
import com.x.base.core.project.config.Token;
import com.x.base.core.project.config.Vfs;
import com.x.base.core.project.config.Web;
import com.x.base.core.project.config.WorkTime;
import com.x.base.core.project.config.ZhengwuDingding;
import com.x.base.core.project.gson.XGsonBuilder;
......@@ -81,7 +80,7 @@ public class CreateConfigSample {
classes.add(WorkTime.class);
classes.add(ZhengwuDingding.class);
classes.add(Cache.class);
classes.add(Web.class);
//classes.add(Web.class);
Collections.sort(classes, new Comparator<Class<?>>() {
public int compare(Class<?> c1, Class<?> c2) {
......
......@@ -1166,13 +1166,13 @@ public class Config {
return instance().components;
}
public Web web;
public JsonObject web;
public static synchronized Web web() throws Exception {
public static synchronized JsonObject web() throws Exception {
if (null == instance().web) {
Web obj = BaseTools.readConfigObject(PATH_CONFIG_WEB, Web.class);
JsonObject obj = BaseTools.readConfigObject(PATH_CONFIG_WEB, JsonObject.class);
if (null == obj) {
obj = Web.defaultInstance();
obj = new JsonObject();
}
instance().web = obj;
}
......
package com.x.base.core.project.config;
import java.util.TreeMap;
import com.x.base.core.project.annotation.FieldDescribe;
public class Web extends ConfigObject {
private static final long serialVersionUID = -1549522764856326338L;
public static Web defaultInstance() {
return new Web();
}
public Web() {
}
@FieldDescribe("使用Post模拟Put,Get模拟Delete的模块.")
private Mock mock = new Mock();
public static class Mock extends TreeMap<String, MockItem> {
}
public Mock getMock() {
return mock;
}
public void setMock(Mock mock) {
this.mock = mock;
}
public static class MockItem {
private MockItemObject put;
private MockItemObject delete;
}
public static class MockItemObject {
private String to;
private String append;
}
}
......@@ -4,7 +4,6 @@ import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
......@@ -33,6 +32,7 @@ import org.eclipse.jetty.webapp.WebAppContext;
import com.alibaba.druid.support.http.StatViewServlet;
import com.alibaba.druid.support.http.WebStatFilter;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.x.base.core.project.x_program_center;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.config.WebServer;
......@@ -252,7 +252,9 @@ public class WebServerTools extends JettySeverTools {
publicKey = new String(Base64.encodeBase64(publicKeyB));
map.put("publicKey", publicKey);
}
map.put("mock", Config.web().getMock());
for (Entry<String, JsonElement> en : Config.web().entrySet()) {
map.put(en.getKey(), en.getValue());
}
FileUtils.writeStringToFile(file, gson.toJson(map), DefaultCharset.charset);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册