package com.ruoyi.message.config; import org.springframework.boot.context.properties.bind.Bindable; import org.springframework.boot.context.properties.bind.Binder; import org.springframework.boot.context.properties.source.ConfigurationPropertyName; import org.springframework.boot.context.properties.source.ConfigurationPropertySources; import org.springframework.boot.env.YamlPropertySourceLoader; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.PropertySource; import org.springframework.core.env.StandardEnvironment; import org.springframework.core.io.FileSystemResource; import java.util.List; /** * 用「各站点真实的 application-*.yml」逐站点校验存量扁平 key 的绑定。 *
* 只关心短信/公众号相关 key,其余 key 即使带占位符也不影响。
*/
public final class PerSiteBindingCheck {
private static int failed = 0;
private PerSiteBindingCheck() {
}
public static void main(String[] args) throws Exception {
String resDir = args.length > 0 ? args[0]
: "ruoyi-admin/src/main/resources";
checkSite(resDir, "xh", "新华",
new String[]{"http://192.16.4.220:8092/sms", "911124", "zW5eXe", "1069055"},
null, null);
checkSite(resDir, "hzszlyy", "市一",
new String[]{"http://192.169.140.240:8001/sms/api/sendMessageMass", "300044", "qj0NHDegxWhj", "1069055"},
null, null);
checkSite(resDir, "sltd", "省立同德",
new String[]{"", "", "", ""},
null, null);
checkSite(resDir, "nhfy", "南华附一",
new String[]{"", "", "", ""},
new String[]{"S200232", "lD94Yo", "http://open.nhyfy.cn/kapi/gw-api/hntypt/ucpmsg/send",
"1069100020341", "PUSH", "ak-BFq4NN0TMf92J7KAioNYGz74", "【南华大学附属第一医院】"},
null);
System.out.println();
if (failed == 0) {
System.out.println("===== 逐站点绑定校验全部通过 =====");
} else {
System.out.println("===== 逐站点绑定校验失败 " + failed + " 项 =====");
System.exit(1);
}
}
private static void checkSite(String resDir, String profile, String siteName,
String[] xhsms, String[] mt, String[] aliyun) throws Exception {
String file = resDir + "/application-" + profile + ".yml";
System.out.println("========== " + siteName + "(" + file + ")==========");
ConfigurableEnvironment environment = new StandardEnvironment();
environment.getPropertySources()
.remove(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME);
environment.getPropertySources()
.remove(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME);
List