1:修改maat和非maat类配置下发为多数据源下发
2:修改servicetable.properties 3:添加配置下发模块
This commit is contained in:
56
src/main/java/com/nis/util/CamelUnderlineUtil.java
Normal file
56
src/main/java/com/nis/util/CamelUnderlineUtil.java
Normal file
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.nis.util;
|
||||
|
||||
/**
|
||||
* @ClassName:CamelUnderlineUtil
|
||||
* @Description:TODO(这里用一句话描述这个类的作用)
|
||||
* @author (zdx)
|
||||
* @date 2018年5月25日 下午4:44:54
|
||||
* @version V1.0
|
||||
*/
|
||||
public class CamelUnderlineUtil {
|
||||
|
||||
private static final char UNDERLINE ='_';
|
||||
public static String camelToUnderline(String param) {
|
||||
|
||||
if (StringUtil.isEmpty(param)) {
|
||||
|
||||
return "";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int len = param.length();
|
||||
for (int i = 0; i < len; i++) {
|
||||
char c = param.charAt(i);
|
||||
if (Character.isUpperCase(c)) {
|
||||
sb.append(UNDERLINE);
|
||||
sb.append(Character.toLowerCase(c));
|
||||
} else {
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String underlineToCamel(String param){
|
||||
|
||||
if (StringUtil.isEmpty(param)) {
|
||||
|
||||
return "";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int len = param.length();
|
||||
for (int i = 0; i < len; i++) {
|
||||
char c = param.charAt(i);
|
||||
if (c==UNDERLINE) {
|
||||
if(++i<len){
|
||||
sb.append(Character.toUpperCase(param.charAt(i)));
|
||||
}
|
||||
} else {
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -447,8 +447,8 @@ public class CompileJudge {
|
||||
if (null == configCompile.getAction()) {
|
||||
return "id为" + compileId + "的编译配置中action不能为空";
|
||||
}
|
||||
if (null == configCompile.getDoBlackList()) {
|
||||
return "id为" + compileId + "的编译配置中doBlackList不能为空";
|
||||
if (null == configCompile.getDoBlacklist()) {
|
||||
return "id为" + compileId + "的编译配置中doBlacklist不能为空";
|
||||
}
|
||||
if (null == configCompile.getDoLog()) {
|
||||
return "id为" + compileId + "的编译配置中doLog不能为空";
|
||||
|
||||
@@ -423,8 +423,8 @@ public class CompileVal {
|
||||
if (null == configCompile.getAction()) {
|
||||
return "id为" + compileId + "的编译配置中action不能为空";
|
||||
}
|
||||
if (null == configCompile.getDoBlackList()) {
|
||||
return "id为" + compileId + "的编译配置中doBlackList不能为空";
|
||||
if (null == configCompile.getDoBlacklist()) {
|
||||
return "id为" + compileId + "的编译配置中doBlacklist不能为空";
|
||||
}
|
||||
if (null == configCompile.getDoLog()) {
|
||||
return "id为" + compileId + "的编译配置中doLog不能为空";
|
||||
@@ -686,8 +686,8 @@ public class CompileVal {
|
||||
&& configCompile.getAction() != 6 && configCompile.getAction() != 7) {
|
||||
return "编译配置id为" + compileId + "的配置中action的值只能是1(阻断),2(监测),5(封堵白名单),6(监测白名单),7(封堵监测都白名单)";
|
||||
}
|
||||
if (configCompile.getDoBlackList() != 1) {
|
||||
return "编译配置id为" + compileId + "的配置中doBlackList的值只能是1";
|
||||
if (configCompile.getDoBlacklist() != 1) {
|
||||
return "编译配置id为" + compileId + "的配置中doBlacklist的值只能是1";
|
||||
}
|
||||
|
||||
if (configCompile.getDoLog() != 0 && configCompile.getDoLog() != 1 && configCompile.getDoLog() != 2) {
|
||||
|
||||
@@ -45,9 +45,6 @@ public class ReadMaatXmlUtil {
|
||||
static {
|
||||
readXml();
|
||||
}
|
||||
|
||||
private static List<MaatXmlConfig> maatXmlConfigList = new ArrayList<MaatXmlConfig>();
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
// validateXmlByXSD();
|
||||
|
||||
93
src/main/java/com/nis/util/ServiceAndRDBIndexReal.java
Normal file
93
src/main/java/com/nis/util/ServiceAndRDBIndexReal.java
Normal file
@@ -0,0 +1,93 @@
|
||||
package com.nis.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* <p>Title: ServiceAndRDBIndexReal</p>
|
||||
* <p>Description: 业务类型与各个表名的对应关系,业务类型与redisDBIndex的对应关系</p>
|
||||
* <p>Company: IIE</p>
|
||||
* @author rkg
|
||||
* @date 2018年5月30日
|
||||
*
|
||||
*/
|
||||
public class ServiceAndRDBIndexReal {
|
||||
|
||||
/**
|
||||
* 第一个key是业务类型,第二个key是type(编译配置,分组配置,域配置)value是表名
|
||||
*/
|
||||
private static Map<Integer, Map<Integer, String>> sercieNameMap = new HashMap<Integer, Map<Integer, String>>();
|
||||
/**
|
||||
* key是业务类型,value是业务类型对应的redisdbIndex
|
||||
*/
|
||||
private static Map<Integer, Integer> serviceDBIndexmap = new HashMap<Integer, Integer>();
|
||||
|
||||
static {
|
||||
String service = Configurations.getStringProperty("service", "");
|
||||
if (service != null && !service.trim().equals("")) {
|
||||
String[] split = service.split(";");
|
||||
for (String str : split) {
|
||||
String type = Configurations.getStringProperty(str, "");
|
||||
if (type != null && !type.trim().equals("")) {
|
||||
Map<Integer, String> typeMap = new HashMap<Integer, String>();
|
||||
String[] typeArrs = type.split(";");
|
||||
for (String typeStr : typeArrs) {
|
||||
String[] typeArr = typeStr.split(":");
|
||||
String tableNameArr[] = typeArr[1].split(",");
|
||||
for (String tableName : tableNameArr) {
|
||||
typeMap.put(Integer.parseInt(typeArr[0]), tableName.toUpperCase());
|
||||
}
|
||||
}
|
||||
sercieNameMap.put(Integer.parseInt(str), typeMap);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
String serviceDBIndexs = Configurations.getStringProperty("serviceDBIndex", "");
|
||||
if (serviceDBIndexs != null && !serviceDBIndexs.trim().equals("")) {
|
||||
String[] serviceDBIndexArr = serviceDBIndexs.split(";");
|
||||
for (String serviceDBIndexStr : serviceDBIndexArr) {
|
||||
String[] serviceDBIndex = serviceDBIndexStr.split(":");
|
||||
|
||||
String[] redisDbArr = serviceDBIndex[1].split(",");
|
||||
for (String redisDBIndex : redisDbArr) {
|
||||
serviceDBIndexmap.put(Integer.parseInt(serviceDBIndex[0]), Integer.parseInt(redisDBIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Integer getRedisDBByService(Integer service) {
|
||||
Integer redisIndex = serviceDBIndexmap.get(service);
|
||||
if (redisIndex == null) {
|
||||
return 0;
|
||||
}
|
||||
return redisIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据业务类型和具体的type获取对应的表名
|
||||
* @param service 业务类型
|
||||
* @param type 10代表是编译配置,11代表是分组配置,12代表是ip类域配置,13代表是数值类配置,14代表是字符串类域配置,15代表是增强字符串类域配置
|
||||
* @return
|
||||
*/
|
||||
public static String getTableName(int service, int type) {
|
||||
Map<Integer, String> typeMap = sercieNameMap.get(service);
|
||||
if (typeMap != null && typeMap.size() > 0) {
|
||||
return typeMap.get(type);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String str = "80:2";
|
||||
String[] serviceDBIndex = str.split(":");
|
||||
String[] redisDbArr = serviceDBIndex[1].split(",");
|
||||
for (String redisDBIndex : redisDbArr) {
|
||||
System.out.println(redisDBIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user