WANG hace 6 años
padre
commit
16d2385f1c

+ 24 - 1
src/main/java/cn/com/qmth/examcloud/web/cloud/CloudServiceRedirector.java

@@ -15,6 +15,8 @@ public class CloudServiceRedirector {
 
 	private static Map<String, String> rules = Maps.newHashMap();
 
+	private static String suffix;
+
 	/**
 	 * 设置重定向映射
 	 *
@@ -28,6 +30,18 @@ public class CloudServiceRedirector {
 		rules.put(originAppName, targetAppName);
 	}
 
+	/**
+	 * 设置所有服务附加后缀映射.优先级低于 {@link setRedirection}
+	 * 
+	 * @see #setRedirection
+	 *
+	 * @author WANGWEI
+	 * @param suffixName
+	 */
+	public static void appendSuffix(String suffixName) {
+		CloudServiceRedirector.suffix = suffixName;
+	}
+
 	/**
 	 * 获取重定向映射.不存在时返回null
 	 *
@@ -36,7 +50,16 @@ public class CloudServiceRedirector {
 	 * @return
 	 */
 	public static String getRedirection(String originAppName) {
-		return rules.get(originAppName);
+
+		String redirection = rules.get(originAppName);
+		if (null != redirection) {
+			return redirection;
+		}
+		if (null != suffix) {
+			return originAppName + suffix;
+		}
+
+		return null;
 	}
 
 }