diff --git a/guerlab-sms-aliyun-starter/pom.xml b/guerlab-sms-aliyun-starter/pom.xml index 98af59e89b2cfcaff4ccbf676734795252895b2e..816ba2f7f1bf97fec502a9e9ab815956d70f0c22 100644 --- a/guerlab-sms-aliyun-starter/pom.xml +++ b/guerlab-sms-aliyun-starter/pom.xml @@ -21,15 +21,20 @@ ${revision} + + net.guerlab.sms + guerlab-sms-server-starter + + org.springframework.boot spring-boot-configuration-processor true - - - org.springframework.boot - spring-boot-starter-test + + + org.springframework.boot + spring-boot-starter-test test - - + + diff --git a/guerlab-sms-aliyun-starter/src/main/java/net/guerlab/sms/aliyun/AliyunAutoConfigure.java b/guerlab-sms-aliyun-starter/src/main/java/net/guerlab/sms/aliyun/AliyunAutoConfigure.java index 6391086e555c1481444341749cb8b59e8a4170aa..d5a942c309e44307231330c9daa861d50a111429 100644 --- a/guerlab-sms-aliyun-starter/src/main/java/net/guerlab/sms/aliyun/AliyunAutoConfigure.java +++ b/guerlab-sms-aliyun-starter/src/main/java/net/guerlab/sms/aliyun/AliyunAutoConfigure.java @@ -13,8 +13,8 @@ package net.guerlab.sms.aliyun; import com.fasterxml.jackson.databind.ObjectMapper; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.loadbalancer.SmsSenderLoadBalancer; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -30,7 +30,7 @@ import org.springframework.core.type.AnnotatedTypeMetadata; */ @Configuration @EnableConfigurationProperties(AliyunProperties.class) -@AutoConfigureAfter(SmsConfiguration.class) +@AutoConfigureAfter(SmsAutoConfiguration.class) public class AliyunAutoConfigure { /** diff --git a/guerlab-sms-aliyun-starter/src/test/java/net/guerlab/sms/aliyun/AliyunAutoConfigureTest.java b/guerlab-sms-aliyun-starter/src/test/java/net/guerlab/sms/aliyun/AliyunAutoConfigureTest.java index d6f375280161fbf17dc500b43bef98635b03a9a7..ae4dccedd76ac19c3948d191cf5a7fa16b8ec365 100644 --- a/guerlab-sms-aliyun-starter/src/test/java/net/guerlab/sms/aliyun/AliyunAutoConfigureTest.java +++ b/guerlab-sms-aliyun-starter/src/test/java/net/guerlab/sms/aliyun/AliyunAutoConfigureTest.java @@ -13,8 +13,9 @@ package net.guerlab.sms.aliyun; import com.fasterxml.jackson.databind.ObjectMapper; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.loadbalancer.RandomSmsLoadBalancer; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; +import net.guerlab.sms.server.spring.autoconfigure.VerificationCodeAutoConfiguration; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -34,7 +35,8 @@ public class AliyunAutoConfigureTest { context = new AnnotationConfigApplicationContext(); context.registerBean("objectMapper", ObjectMapper.class); context.registerBean("smsSenderLoadbalancer", RandomSmsLoadBalancer.class); - context.register(SmsConfiguration.class); + context.register(SmsAutoConfiguration.class); + context.register(VerificationCodeAutoConfiguration.class); } @After diff --git a/guerlab-sms-aliyun/pom.xml b/guerlab-sms-aliyun/pom.xml index 7240750719c84730d17a30b73fb6a7cef26e4afa..c1c0f038d35b53fb08f84a754cfcfa633eec4b24 100644 --- a/guerlab-sms-aliyun/pom.xml +++ b/guerlab-sms-aliyun/pom.xml @@ -17,7 +17,7 @@ net.guerlab.sms - guerlab-sms-server-starter + guerlab-sms-server org.springframework.boot diff --git a/guerlab-sms-baiducloud-starter/pom.xml b/guerlab-sms-baiducloud-starter/pom.xml index 217699ae3083f492ee3395c912db26965ca8945f..d1998b4650e1c6bc3ffa2e6c088ae9de1db3d8c3 100644 --- a/guerlab-sms-baiducloud-starter/pom.xml +++ b/guerlab-sms-baiducloud-starter/pom.xml @@ -20,6 +20,11 @@ guerlab-sms-baiducloud + + net.guerlab.sms + guerlab-sms-server-starter + + org.springframework.boot spring-boot-configuration-processor diff --git a/guerlab-sms-baiducloud-starter/src/main/java/net/guerlab/sms/baiducloud/BaiduCloudAutoConfigure.java b/guerlab-sms-baiducloud-starter/src/main/java/net/guerlab/sms/baiducloud/BaiduCloudAutoConfigure.java index 8d9dc9d0aebea9d136c21753b5bb3fca3ca41780..edca79e72f7a8e84996a637f059e7311b978db01 100644 --- a/guerlab-sms-baiducloud-starter/src/main/java/net/guerlab/sms/baiducloud/BaiduCloudAutoConfigure.java +++ b/guerlab-sms-baiducloud-starter/src/main/java/net/guerlab/sms/baiducloud/BaiduCloudAutoConfigure.java @@ -12,8 +12,8 @@ */ package net.guerlab.sms.baiducloud; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.loadbalancer.SmsSenderLoadBalancer; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -28,7 +28,7 @@ import org.springframework.core.type.AnnotatedTypeMetadata; */ @Configuration @EnableConfigurationProperties(BaiduCloudProperties.class) -@AutoConfigureAfter(SmsConfiguration.class) +@AutoConfigureAfter(SmsAutoConfiguration.class) public class BaiduCloudAutoConfigure { /** diff --git a/guerlab-sms-baiducloud-starter/src/test/java/net/guerlab/sms/baiducloud/BaiduCloudAutoConfigureTest.java b/guerlab-sms-baiducloud-starter/src/test/java/net/guerlab/sms/baiducloud/BaiduCloudAutoConfigureTest.java index c28a6dc145167e5f1c50ccdebf014e344b8847c8..74a07e0f2d916c39cb529a470a080e14da58cc92 100644 --- a/guerlab-sms-baiducloud-starter/src/test/java/net/guerlab/sms/baiducloud/BaiduCloudAutoConfigureTest.java +++ b/guerlab-sms-baiducloud-starter/src/test/java/net/guerlab/sms/baiducloud/BaiduCloudAutoConfigureTest.java @@ -13,8 +13,8 @@ package net.guerlab.sms.baiducloud; import com.fasterxml.jackson.databind.ObjectMapper; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.loadbalancer.RandomSmsLoadBalancer; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -34,7 +34,7 @@ public class BaiduCloudAutoConfigureTest { context = new AnnotationConfigApplicationContext(); context.registerBean("objectMapper", ObjectMapper.class); context.registerBean("smsSenderLoadbalancer", RandomSmsLoadBalancer.class); - context.register(SmsConfiguration.class); + context.register(SmsAutoConfiguration.class); TestPropertyValues.of("sms.baiducloud.access-key-id=accessKeyId").applyTo(context); TestPropertyValues.of("sms.baiducloud.secret-access-key=secretAccessKey").applyTo(context); TestPropertyValues.of("sms.baiducloud.endpoint=endpoint").applyTo(context); diff --git a/guerlab-sms-baiducloud/pom.xml b/guerlab-sms-baiducloud/pom.xml index b3ce9422ad0bf30fb64a910428cac8b474e1108a..e394a7ba1e186ffa5c102cf0762e9f603cdf0d82 100644 --- a/guerlab-sms-baiducloud/pom.xml +++ b/guerlab-sms-baiducloud/pom.xml @@ -17,7 +17,7 @@ net.guerlab.sms - guerlab-sms-server-starter + guerlab-sms-server org.springframework.boot diff --git a/guerlab-sms-chinamobile-starter/pom.xml b/guerlab-sms-chinamobile-starter/pom.xml index 8e799e8f05ecc8a622b704d530507644d4a3e42f..54d7a26e0db61bcc14a0eb618cfaeb214dba3145 100644 --- a/guerlab-sms-chinamobile-starter/pom.xml +++ b/guerlab-sms-chinamobile-starter/pom.xml @@ -21,6 +21,11 @@ guerlab-sms-chinamobile + + net.guerlab.sms + guerlab-sms-server-starter + + org.springframework.boot spring-boot-configuration-processor diff --git a/guerlab-sms-chinamobile-starter/src/main/java/net/guerlab/sms/chinamobile/ChinaMobileAutoConfigure.java b/guerlab-sms-chinamobile-starter/src/main/java/net/guerlab/sms/chinamobile/ChinaMobileAutoConfigure.java index 50198dcd68cfc20cce18e921a57e5bf3065bc2c7..0003c9dbd51e3aba42a83b64d99958ba5893a867 100644 --- a/guerlab-sms-chinamobile-starter/src/main/java/net/guerlab/sms/chinamobile/ChinaMobileAutoConfigure.java +++ b/guerlab-sms-chinamobile-starter/src/main/java/net/guerlab/sms/chinamobile/ChinaMobileAutoConfigure.java @@ -13,8 +13,8 @@ package net.guerlab.sms.chinamobile; import com.fasterxml.jackson.databind.ObjectMapper; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.loadbalancer.SmsSenderLoadBalancer; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -30,7 +30,7 @@ import org.springframework.web.client.RestTemplate; */ @Configuration @EnableConfigurationProperties(ChinaMobileProperties.class) -@AutoConfigureAfter(SmsConfiguration.class) +@AutoConfigureAfter(SmsAutoConfiguration.class) public class ChinaMobileAutoConfigure { /** diff --git a/guerlab-sms-chinamobile-starter/src/test/java/net/guerlab/sms/chinamobile/ChinaMobileAutoConfigureTest.java b/guerlab-sms-chinamobile-starter/src/test/java/net/guerlab/sms/chinamobile/ChinaMobileAutoConfigureTest.java index bc1759d20da8be1f0a9dcb0f2ba4b863780d68b7..da8d17ad6bb3e2fc5d8632cbd6a7c7fc52c54f41 100644 --- a/guerlab-sms-chinamobile-starter/src/test/java/net/guerlab/sms/chinamobile/ChinaMobileAutoConfigureTest.java +++ b/guerlab-sms-chinamobile-starter/src/test/java/net/guerlab/sms/chinamobile/ChinaMobileAutoConfigureTest.java @@ -13,8 +13,8 @@ package net.guerlab.sms.chinamobile; import com.fasterxml.jackson.databind.ObjectMapper; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.loadbalancer.RandomSmsLoadBalancer; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -34,7 +34,7 @@ public class ChinaMobileAutoConfigureTest { context = new AnnotationConfigApplicationContext(); context.registerBean("objectMapper", ObjectMapper.class); context.registerBean("smsSenderLoadbalancer", RandomSmsLoadBalancer.class); - context.register(SmsConfiguration.class); + context.register(SmsAutoConfiguration.class); } @After diff --git a/guerlab-sms-chinamobile/pom.xml b/guerlab-sms-chinamobile/pom.xml index 84b05ae1e60cfe236de5082ab0cfd721dd094673..6ca4bc9512781af64e5aef9924373ac29223ff2c 100644 --- a/guerlab-sms-chinamobile/pom.xml +++ b/guerlab-sms-chinamobile/pom.xml @@ -18,7 +18,7 @@ net.guerlab.sms - guerlab-sms-server-starter + guerlab-sms-server org.springframework.boot diff --git a/guerlab-sms-huaweicloud-starter/pom.xml b/guerlab-sms-huaweicloud-starter/pom.xml index c67899e27241bb431d5110d2d18851d1406c16be..058650dcd70d4e36aef1f05e9bd16aa9a2022874 100644 --- a/guerlab-sms-huaweicloud-starter/pom.xml +++ b/guerlab-sms-huaweicloud-starter/pom.xml @@ -21,6 +21,11 @@ guerlab-sms-huaweicloud + + net.guerlab.sms + guerlab-sms-server-starter + + org.springframework.boot spring-boot-configuration-processor diff --git a/guerlab-sms-huaweicloud-starter/src/main/java/net/guerlab/sms/huaweicloud/HuaWeiCloudAutoConfigure.java b/guerlab-sms-huaweicloud-starter/src/main/java/net/guerlab/sms/huaweicloud/HuaWeiCloudAutoConfigure.java index 7816c4366dd772d78673d42fc978ee481c20696e..1621c66a4bcb88ef2936e49ec556569e8aa27765 100644 --- a/guerlab-sms-huaweicloud-starter/src/main/java/net/guerlab/sms/huaweicloud/HuaWeiCloudAutoConfigure.java +++ b/guerlab-sms-huaweicloud-starter/src/main/java/net/guerlab/sms/huaweicloud/HuaWeiCloudAutoConfigure.java @@ -13,8 +13,8 @@ package net.guerlab.sms.huaweicloud; import com.fasterxml.jackson.databind.ObjectMapper; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.loadbalancer.SmsSenderLoadBalancer; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -30,7 +30,7 @@ import org.springframework.web.client.RestTemplate; */ @Configuration @EnableConfigurationProperties(HuaWeiCloudProperties.class) -@AutoConfigureAfter(SmsConfiguration.class) +@AutoConfigureAfter(SmsAutoConfiguration.class) public class HuaWeiCloudAutoConfigure { /** diff --git a/guerlab-sms-huaweicloud-starter/src/test/java/net/guerlab/sms/huaweicloud/HuaWeiCloudAutoConfigureTest.java b/guerlab-sms-huaweicloud-starter/src/test/java/net/guerlab/sms/huaweicloud/HuaWeiCloudAutoConfigureTest.java index e1fe53fb95d4a34ed11df76216ae83351e778502..6c3c3234506f6ec9994b70453144babd12107850 100644 --- a/guerlab-sms-huaweicloud-starter/src/test/java/net/guerlab/sms/huaweicloud/HuaWeiCloudAutoConfigureTest.java +++ b/guerlab-sms-huaweicloud-starter/src/test/java/net/guerlab/sms/huaweicloud/HuaWeiCloudAutoConfigureTest.java @@ -13,8 +13,8 @@ package net.guerlab.sms.huaweicloud; import com.fasterxml.jackson.databind.ObjectMapper; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.loadbalancer.RandomSmsLoadBalancer; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -34,7 +34,7 @@ public class HuaWeiCloudAutoConfigureTest { context = new AnnotationConfigApplicationContext(); context.registerBean("objectMapper", ObjectMapper.class); context.registerBean("smsSenderLoadbalancer", RandomSmsLoadBalancer.class); - context.register(SmsConfiguration.class); + context.register(SmsAutoConfiguration.class); } @After diff --git a/guerlab-sms-huaweicloud/pom.xml b/guerlab-sms-huaweicloud/pom.xml index f22ebe9846e2a5cb431915b26b5eb679b1334ecc..022a6751e18372d0c142e0e4392bf5f5fc65574b 100644 --- a/guerlab-sms-huaweicloud/pom.xml +++ b/guerlab-sms-huaweicloud/pom.xml @@ -18,7 +18,7 @@ net.guerlab.sms - guerlab-sms-server-starter + guerlab-sms-server org.springframework.boot diff --git a/guerlab-sms-jdcloud-starter/pom.xml b/guerlab-sms-jdcloud-starter/pom.xml index f2ec537f0f2e26a1ff52ef78cc7d9145cf92b07f..1b92eb384ebb2068f9de6c8b1a2385f9eff4ba9a 100644 --- a/guerlab-sms-jdcloud-starter/pom.xml +++ b/guerlab-sms-jdcloud-starter/pom.xml @@ -20,6 +20,11 @@ guerlab-sms-jdcloud + + net.guerlab.sms + guerlab-sms-server-starter + + org.springframework.boot spring-boot-configuration-processor diff --git a/guerlab-sms-jdcloud-starter/src/main/java/net/guerlab/sms/jdcloud/JdCloudAutoConfigure.java b/guerlab-sms-jdcloud-starter/src/main/java/net/guerlab/sms/jdcloud/JdCloudAutoConfigure.java index f969651bd63c586465efe2bd885c3676f6a0e6e9..54a1c08d8701da706309a8affb313552949d23fd 100644 --- a/guerlab-sms-jdcloud-starter/src/main/java/net/guerlab/sms/jdcloud/JdCloudAutoConfigure.java +++ b/guerlab-sms-jdcloud-starter/src/main/java/net/guerlab/sms/jdcloud/JdCloudAutoConfigure.java @@ -12,8 +12,8 @@ */ package net.guerlab.sms.jdcloud; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.loadbalancer.SmsSenderLoadBalancer; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -28,7 +28,7 @@ import org.springframework.core.type.AnnotatedTypeMetadata; */ @Configuration @EnableConfigurationProperties(JdCloudProperties.class) -@AutoConfigureAfter(SmsConfiguration.class) +@AutoConfigureAfter(SmsAutoConfiguration.class) public class JdCloudAutoConfigure { /** diff --git a/guerlab-sms-jdcloud-starter/src/test/java/net/guerlab/sms/jdcloud/JdCloudAutoConfigureTest.java b/guerlab-sms-jdcloud-starter/src/test/java/net/guerlab/sms/jdcloud/JdCloudAutoConfigureTest.java index 494185dab517c9e057b5500988371197489c1953..14b7a2ea341cd3f6a7e113a4e89a340d24d6175b 100644 --- a/guerlab-sms-jdcloud-starter/src/test/java/net/guerlab/sms/jdcloud/JdCloudAutoConfigureTest.java +++ b/guerlab-sms-jdcloud-starter/src/test/java/net/guerlab/sms/jdcloud/JdCloudAutoConfigureTest.java @@ -13,8 +13,8 @@ package net.guerlab.sms.jdcloud; import com.fasterxml.jackson.databind.ObjectMapper; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.loadbalancer.RandomSmsLoadBalancer; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -34,7 +34,7 @@ public class JdCloudAutoConfigureTest { context = new AnnotationConfigApplicationContext(); context.registerBean("objectMapper", ObjectMapper.class); context.registerBean("smsSenderLoadbalancer", RandomSmsLoadBalancer.class); - context.register(SmsConfiguration.class); + context.register(SmsAutoConfiguration.class); } @After diff --git a/guerlab-sms-jdcloud/pom.xml b/guerlab-sms-jdcloud/pom.xml index 7ea96cbe114d0d1f9df173ad61933cd6b1b721df..1f4d8a76eaae3c2d3ccad2627ec3b766afbd5ac5 100644 --- a/guerlab-sms-jdcloud/pom.xml +++ b/guerlab-sms-jdcloud/pom.xml @@ -17,7 +17,7 @@ net.guerlab.sms - guerlab-sms-server-starter + guerlab-sms-server org.springframework.boot diff --git a/guerlab-sms-jpush-starter/pom.xml b/guerlab-sms-jpush-starter/pom.xml index 6fad6d734b920754dbda75070888dba72e826590..95b36b813ea923047c6ce123089de81e8117b56c 100644 --- a/guerlab-sms-jpush-starter/pom.xml +++ b/guerlab-sms-jpush-starter/pom.xml @@ -20,6 +20,11 @@ guerlab-sms-jpush + + net.guerlab.sms + guerlab-sms-server-starter + + org.springframework.boot spring-boot-configuration-processor diff --git a/guerlab-sms-jpush-starter/src/main/java/net/guerlab/sms/jpush/JPushAutoConfigure.java b/guerlab-sms-jpush-starter/src/main/java/net/guerlab/sms/jpush/JPushAutoConfigure.java index 0f9cf6544a35b343404866b8838dc644bbbad737..6a630606789f3ddda34641eda370bd1d4d03b754 100644 --- a/guerlab-sms-jpush-starter/src/main/java/net/guerlab/sms/jpush/JPushAutoConfigure.java +++ b/guerlab-sms-jpush-starter/src/main/java/net/guerlab/sms/jpush/JPushAutoConfigure.java @@ -13,8 +13,8 @@ package net.guerlab.sms.jpush; import com.fasterxml.jackson.databind.ObjectMapper; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.loadbalancer.SmsSenderLoadBalancer; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -31,7 +31,7 @@ import org.springframework.web.client.RestTemplate; @SuppressWarnings("AlibabaClassNamingShouldBeCamel") @Configuration @EnableConfigurationProperties(JPushProperties.class) -@AutoConfigureAfter(SmsConfiguration.class) +@AutoConfigureAfter(SmsAutoConfiguration.class) public class JPushAutoConfigure { /** diff --git a/guerlab-sms-jpush-starter/src/test/java/net/guerlab/sms/jpush/JPushAutoConfigureTest.java b/guerlab-sms-jpush-starter/src/test/java/net/guerlab/sms/jpush/JPushAutoConfigureTest.java index 895100397a192f4e2259be21a6a03aebe3a01bf7..50863590b26f849f4fe4ca22ea9344c8699f80a6 100644 --- a/guerlab-sms-jpush-starter/src/test/java/net/guerlab/sms/jpush/JPushAutoConfigureTest.java +++ b/guerlab-sms-jpush-starter/src/test/java/net/guerlab/sms/jpush/JPushAutoConfigureTest.java @@ -13,8 +13,8 @@ package net.guerlab.sms.jpush; import com.fasterxml.jackson.databind.ObjectMapper; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.loadbalancer.RandomSmsLoadBalancer; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -34,7 +34,7 @@ public class JPushAutoConfigureTest { context = new AnnotationConfigApplicationContext(); context.registerBean("objectMapper", ObjectMapper.class); context.registerBean("smsSenderLoadbalancer", RandomSmsLoadBalancer.class); - context.register(SmsConfiguration.class); + context.register(SmsAutoConfiguration.class); } @After diff --git a/guerlab-sms-jpush/pom.xml b/guerlab-sms-jpush/pom.xml index 8c956d99cddec65fa0905baa21bf414f3d8e2363..9fea2c42d88f4e041e48bc771e813d911459a874 100644 --- a/guerlab-sms-jpush/pom.xml +++ b/guerlab-sms-jpush/pom.xml @@ -17,7 +17,7 @@ net.guerlab.sms - guerlab-sms-server-starter + guerlab-sms-server org.springframework.boot diff --git a/guerlab-sms-netease-starter/pom.xml b/guerlab-sms-netease-starter/pom.xml index a6aff1b66a5517be5b1a6df3333a039d0657cf73..0e0a9b384b02587014f0bf5e48cc19edb97c606d 100644 --- a/guerlab-sms-netease-starter/pom.xml +++ b/guerlab-sms-netease-starter/pom.xml @@ -21,6 +21,11 @@ guerlab-sms-netease + + net.guerlab.sms + guerlab-sms-server-starter + + org.springframework.boot spring-boot-configuration-processor diff --git a/guerlab-sms-netease-starter/src/main/java/net/guerlab/sms/netease/NeteaseCloudAutoConfigure.java b/guerlab-sms-netease-starter/src/main/java/net/guerlab/sms/netease/NeteaseCloudAutoConfigure.java index dd7a3b64c2d8295532f50a7c1cfb71910732aeb7..312e758f7b30761fefc54cb503d7d620ca985682 100644 --- a/guerlab-sms-netease-starter/src/main/java/net/guerlab/sms/netease/NeteaseCloudAutoConfigure.java +++ b/guerlab-sms-netease-starter/src/main/java/net/guerlab/sms/netease/NeteaseCloudAutoConfigure.java @@ -13,8 +13,8 @@ package net.guerlab.sms.netease; import com.fasterxml.jackson.databind.ObjectMapper; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.loadbalancer.SmsSenderLoadBalancer; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -30,7 +30,7 @@ import org.springframework.web.client.RestTemplate; */ @Configuration @EnableConfigurationProperties(NeteaseCloudProperties.class) -@AutoConfigureAfter(SmsConfiguration.class) +@AutoConfigureAfter(SmsAutoConfiguration.class) public class NeteaseCloudAutoConfigure { /** diff --git a/guerlab-sms-netease-starter/src/test/java/net/guerlab/sms/netease/NeteaseCloudAutoConfigureTest.java b/guerlab-sms-netease-starter/src/test/java/net/guerlab/sms/netease/NeteaseCloudAutoConfigureTest.java index 49925d9ed6dc78b098ab3c1dd3cbb3ac246b1f80..74a078a2e99fea38ccbed79b8a5d482218123ec7 100644 --- a/guerlab-sms-netease-starter/src/test/java/net/guerlab/sms/netease/NeteaseCloudAutoConfigureTest.java +++ b/guerlab-sms-netease-starter/src/test/java/net/guerlab/sms/netease/NeteaseCloudAutoConfigureTest.java @@ -13,8 +13,8 @@ package net.guerlab.sms.netease; import com.fasterxml.jackson.databind.ObjectMapper; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.loadbalancer.RandomSmsLoadBalancer; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -34,7 +34,7 @@ public class NeteaseCloudAutoConfigureTest { context = new AnnotationConfigApplicationContext(); context.registerBean("objectMapper", ObjectMapper.class); context.registerBean("smsSenderLoadbalancer", RandomSmsLoadBalancer.class); - context.register(SmsConfiguration.class); + context.register(SmsAutoConfiguration.class); } @After diff --git a/guerlab-sms-netease/pom.xml b/guerlab-sms-netease/pom.xml index fa4ebad0ba4f2a7840b9fd0a2b608cbbc61033d6..4b4fe53db4a7ab84277f8d370764cf0a7504e154 100644 --- a/guerlab-sms-netease/pom.xml +++ b/guerlab-sms-netease/pom.xml @@ -18,7 +18,7 @@ net.guerlab.sms - guerlab-sms-server-starter + guerlab-sms-server org.springframework.boot diff --git a/guerlab-sms-qcloud-starter/pom.xml b/guerlab-sms-qcloud-starter/pom.xml index 7ae6703cbc9f308a4307b660025cd3c0aa59f9f3..b1f3f30ce9ef77259e686b0c5d2702230d1708b1 100644 --- a/guerlab-sms-qcloud-starter/pom.xml +++ b/guerlab-sms-qcloud-starter/pom.xml @@ -20,6 +20,11 @@ guerlab-sms-qcloud + + net.guerlab.sms + guerlab-sms-server-starter + + org.springframework.boot spring-boot-configuration-processor diff --git a/guerlab-sms-qcloud-starter/src/main/java/net/guerlab/sms/qcloud/QCloudAutoConfigure.java b/guerlab-sms-qcloud-starter/src/main/java/net/guerlab/sms/qcloud/QCloudAutoConfigure.java index fffd5f62da4c3d20f1e4c24ac95fa850e311febc..325778fd260e0937d52f90f1c9bf4773b9a22f1e 100644 --- a/guerlab-sms-qcloud-starter/src/main/java/net/guerlab/sms/qcloud/QCloudAutoConfigure.java +++ b/guerlab-sms-qcloud-starter/src/main/java/net/guerlab/sms/qcloud/QCloudAutoConfigure.java @@ -12,8 +12,8 @@ */ package net.guerlab.sms.qcloud; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.loadbalancer.SmsSenderLoadBalancer; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -30,7 +30,7 @@ import org.springframework.core.type.AnnotatedTypeMetadata; @SuppressWarnings("AlibabaClassNamingShouldBeCamel") @Configuration @EnableConfigurationProperties(QCloudProperties.class) -@AutoConfigureAfter(SmsConfiguration.class) +@AutoConfigureAfter(SmsAutoConfiguration.class) public class QCloudAutoConfigure { /** diff --git a/guerlab-sms-qcloud-starter/src/test/java/net/guerlab/sms/qcloud/QCloudAutoConfigureTest.java b/guerlab-sms-qcloud-starter/src/test/java/net/guerlab/sms/qcloud/QCloudAutoConfigureTest.java index f8f24bdfd8e208c7518b95d87c1d3b273ba60666..c869744c7453231e522b78a221afe94bde6ad74c 100644 --- a/guerlab-sms-qcloud-starter/src/test/java/net/guerlab/sms/qcloud/QCloudAutoConfigureTest.java +++ b/guerlab-sms-qcloud-starter/src/test/java/net/guerlab/sms/qcloud/QCloudAutoConfigureTest.java @@ -13,8 +13,8 @@ package net.guerlab.sms.qcloud; import com.fasterxml.jackson.databind.ObjectMapper; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.loadbalancer.RandomSmsLoadBalancer; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -34,7 +34,7 @@ public class QCloudAutoConfigureTest { context = new AnnotationConfigApplicationContext(); context.registerBean("objectMapper", ObjectMapper.class); context.registerBean("smsSenderLoadbalancer", RandomSmsLoadBalancer.class); - context.register(SmsConfiguration.class); + context.register(SmsAutoConfiguration.class); } @After diff --git a/guerlab-sms-qcloud-v3-starter/pom.xml b/guerlab-sms-qcloud-v3-starter/pom.xml index 8adb4bc39fd9a01fa771478827196fd0f8c7b120..2d06f4e33457a0f3c94f3419ebf028189a378400 100644 --- a/guerlab-sms-qcloud-v3-starter/pom.xml +++ b/guerlab-sms-qcloud-v3-starter/pom.xml @@ -20,6 +20,11 @@ guerlab-sms-qcloud-v3 + + net.guerlab.sms + guerlab-sms-server-starter + + org.springframework.boot spring-boot-configuration-processor diff --git a/guerlab-sms-qcloud-v3-starter/src/main/java/net/guerlab/sms/qcloudv3/QCloudV3AutoConfigure.java b/guerlab-sms-qcloud-v3-starter/src/main/java/net/guerlab/sms/qcloudv3/QCloudV3AutoConfigure.java index 8a4b8367a39bd1f7983ceda74ef83997f595219e..4d6c8f864c868cdeed962e428e25b33c04b36c50 100644 --- a/guerlab-sms-qcloud-v3-starter/src/main/java/net/guerlab/sms/qcloudv3/QCloudV3AutoConfigure.java +++ b/guerlab-sms-qcloud-v3-starter/src/main/java/net/guerlab/sms/qcloudv3/QCloudV3AutoConfigure.java @@ -12,8 +12,8 @@ */ package net.guerlab.sms.qcloudv3; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.loadbalancer.SmsSenderLoadBalancer; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -29,7 +29,7 @@ import org.springframework.core.type.AnnotatedTypeMetadata; @SuppressWarnings("AlibabaClassNamingShouldBeCamel") @Configuration @EnableConfigurationProperties(QCloudV3Properties.class) -@AutoConfigureAfter(SmsConfiguration.class) +@AutoConfigureAfter(SmsAutoConfiguration.class) public class QCloudV3AutoConfigure { /** diff --git a/guerlab-sms-qcloud-v3-starter/src/test/java/net/guerlab/sms/qcloudv3/QCloudV3AutoConfigureTest.java b/guerlab-sms-qcloud-v3-starter/src/test/java/net/guerlab/sms/qcloudv3/QCloudV3AutoConfigureTest.java index 12c3b0a56dcee3d88404710507dbc9bf2389f25d..e2ea41dabfeb850789665c688bb5837e94ad0c07 100644 --- a/guerlab-sms-qcloud-v3-starter/src/test/java/net/guerlab/sms/qcloudv3/QCloudV3AutoConfigureTest.java +++ b/guerlab-sms-qcloud-v3-starter/src/test/java/net/guerlab/sms/qcloudv3/QCloudV3AutoConfigureTest.java @@ -13,8 +13,8 @@ package net.guerlab.sms.qcloudv3; import com.fasterxml.jackson.databind.ObjectMapper; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.loadbalancer.RandomSmsLoadBalancer; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -34,7 +34,7 @@ public class QCloudV3AutoConfigureTest { context = new AnnotationConfigApplicationContext(); context.registerBean("objectMapper", ObjectMapper.class); context.registerBean("smsSenderLoadbalancer", RandomSmsLoadBalancer.class); - context.register(SmsConfiguration.class); + context.register(SmsAutoConfiguration.class); } @After diff --git a/guerlab-sms-qcloud-v3/pom.xml b/guerlab-sms-qcloud-v3/pom.xml index f7528bad8488c8f90477b298d5eed1498eb0bf1d..3d35cbc19ff62dd6e686154c14513e9115a00402 100644 --- a/guerlab-sms-qcloud-v3/pom.xml +++ b/guerlab-sms-qcloud-v3/pom.xml @@ -17,7 +17,7 @@ net.guerlab.sms - guerlab-sms-server-starter + guerlab-sms-server org.springframework.boot diff --git a/guerlab-sms-qcloud/pom.xml b/guerlab-sms-qcloud/pom.xml index 4b548a13c24d9c1b4ea969f949dcba596325dc15..067460010405eaf1e70ac81371555d4030c68c03 100644 --- a/guerlab-sms-qcloud/pom.xml +++ b/guerlab-sms-qcloud/pom.xml @@ -17,7 +17,7 @@ net.guerlab.sms - guerlab-sms-server-starter + guerlab-sms-server org.springframework.boot diff --git a/guerlab-sms-qiniu-starter/pom.xml b/guerlab-sms-qiniu-starter/pom.xml index 76b35a02a501addfb3474851ddaa431701919170..4b4d102ca2969831911bf68364e85b8807a38088 100644 --- a/guerlab-sms-qiniu-starter/pom.xml +++ b/guerlab-sms-qiniu-starter/pom.xml @@ -20,6 +20,11 @@ guerlab-sms-qiniu + + net.guerlab.sms + guerlab-sms-server-starter + + org.springframework.boot spring-boot-configuration-processor diff --git a/guerlab-sms-qiniu-starter/src/main/java/net/guerlab/sms/qiniu/QiNiuAutoConfigure.java b/guerlab-sms-qiniu-starter/src/main/java/net/guerlab/sms/qiniu/QiNiuAutoConfigure.java index 113df385d6ca4d1c091af75beae030ea699922b9..ea22dfca1ab4cb156b36436956e72cd9d7dcf64e 100644 --- a/guerlab-sms-qiniu-starter/src/main/java/net/guerlab/sms/qiniu/QiNiuAutoConfigure.java +++ b/guerlab-sms-qiniu-starter/src/main/java/net/guerlab/sms/qiniu/QiNiuAutoConfigure.java @@ -12,8 +12,8 @@ */ package net.guerlab.sms.qiniu; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.loadbalancer.SmsSenderLoadBalancer; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -28,7 +28,7 @@ import org.springframework.core.type.AnnotatedTypeMetadata; */ @Configuration @EnableConfigurationProperties(QiNiuProperties.class) -@AutoConfigureAfter(SmsConfiguration.class) +@AutoConfigureAfter(SmsAutoConfiguration.class) public class QiNiuAutoConfigure { /** diff --git a/guerlab-sms-qiniu-starter/src/test/java/net/guerlab/sms/qiniu/QiNiuAutoConfigureTest.java b/guerlab-sms-qiniu-starter/src/test/java/net/guerlab/sms/qiniu/QiNiuAutoConfigureTest.java index 1721a4ec0b8c9210b078ef850d2c8b7f41c00abd..8faf6049154406d83e1c10d205f19037df6cbe4a 100644 --- a/guerlab-sms-qiniu-starter/src/test/java/net/guerlab/sms/qiniu/QiNiuAutoConfigureTest.java +++ b/guerlab-sms-qiniu-starter/src/test/java/net/guerlab/sms/qiniu/QiNiuAutoConfigureTest.java @@ -13,8 +13,8 @@ package net.guerlab.sms.qiniu; import com.fasterxml.jackson.databind.ObjectMapper; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.loadbalancer.RandomSmsLoadBalancer; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -34,7 +34,7 @@ public class QiNiuAutoConfigureTest { context = new AnnotationConfigApplicationContext(); context.registerBean("objectMapper", ObjectMapper.class); context.registerBean("smsSenderLoadbalancer", RandomSmsLoadBalancer.class); - context.register(SmsConfiguration.class); + context.register(SmsAutoConfiguration.class); TestPropertyValues.of("sms.qiniu.access-key=accessKey").applyTo(context); TestPropertyValues.of("sms.qiniu.secret-key=secretKey").applyTo(context); TestPropertyValues.of("sms.qiniu.templates.test=templateId").applyTo(context); diff --git a/guerlab-sms-qiniu/pom.xml b/guerlab-sms-qiniu/pom.xml index 476ef145a32bec382ada86b5e5fa6d2ea76d8159..42434c3eca82c00c733b1076d8adea53f40948b1 100644 --- a/guerlab-sms-qiniu/pom.xml +++ b/guerlab-sms-qiniu/pom.xml @@ -17,7 +17,7 @@ net.guerlab.sms - guerlab-sms-server-starter + guerlab-sms-server org.springframework.boot diff --git a/guerlab-sms-redis-repository-starter/src/main/java/net/guerlab/sms/server/spring/redis/autoconfigure/VerificationCodeRedisRepositoryAutoConfiguration.java b/guerlab-sms-redis-repository-starter/src/main/java/net/guerlab/sms/server/spring/redis/autoconfigure/VerificationCodeRedisRepositoryAutoConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..29e8b3425c1070cd9619aab331dffb4dda76024a --- /dev/null +++ b/guerlab-sms-redis-repository-starter/src/main/java/net/guerlab/sms/server/spring/redis/autoconfigure/VerificationCodeRedisRepositoryAutoConfiguration.java @@ -0,0 +1,42 @@ +/* + * Copyright 2018-2022 the original author or authors. + * + * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.gnu.org/licenses/lgpl-3.0.html + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.guerlab.sms.server.spring.redis.autoconfigure; + +import com.fasterxml.jackson.databind.ObjectMapper; +import net.guerlab.sms.server.repository.VerificationCodeRepository; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; +import net.guerlab.sms.server.spring.redis.properties.RedisProperties; +import net.guerlab.sms.server.spring.redis.repository.VerificationCodeRedisRepository; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.core.RedisTemplate; + +/** + * 验证码redis储存实现自动配置 + * + * @author guer + */ +@Configuration +@AutoConfigureAfter(SmsAutoConfiguration.class) +@EnableConfigurationProperties(RedisProperties.class) +public class VerificationCodeRedisRepositoryAutoConfiguration { + + @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") + @Bean + public VerificationCodeRepository verificationCodeRedisRepository(RedisProperties properties, + RedisTemplate redisTemplate, ObjectMapper objectMapper) { + return new VerificationCodeRedisRepository(properties, redisTemplate, objectMapper); + } +} diff --git a/guerlab-sms-redis-repository-starter/src/main/java/net/guerlab/sms/server/spring/redis/autoconfigure/package-info.java b/guerlab-sms-redis-repository-starter/src/main/java/net/guerlab/sms/server/spring/redis/autoconfigure/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..0239c1db880f34c995ad25da883b999219ecc61b --- /dev/null +++ b/guerlab-sms-redis-repository-starter/src/main/java/net/guerlab/sms/server/spring/redis/autoconfigure/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2018-2021 guerlab.net and other contributors. + * + * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.gnu.org/licenses/lgpl-3.0.html + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @author guer + */ +@NonNullApi +package net.guerlab.sms.server.spring.redis.autoconfigure; + +import org.springframework.lang.NonNullApi; diff --git a/guerlab-sms-redis-repository-starter/src/main/java/net/guerlab/sms/server/properties/RedisProperties.java b/guerlab-sms-redis-repository-starter/src/main/java/net/guerlab/sms/server/spring/redis/properties/RedisProperties.java similarity index 56% rename from guerlab-sms-redis-repository-starter/src/main/java/net/guerlab/sms/server/properties/RedisProperties.java rename to guerlab-sms-redis-repository-starter/src/main/java/net/guerlab/sms/server/spring/redis/properties/RedisProperties.java index c5ba87e85088972bf0be6ff5f5a6d100d53cf152..e61141bab7ce77d2d60de178e82f6dbcff49aff6 100644 --- a/guerlab-sms-redis-repository-starter/src/main/java/net/guerlab/sms/server/properties/RedisProperties.java +++ b/guerlab-sms-redis-repository-starter/src/main/java/net/guerlab/sms/server/spring/redis/properties/RedisProperties.java @@ -10,40 +10,24 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package net.guerlab.sms.server.properties; +package net.guerlab.sms.server.spring.redis.properties; +import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; /** * redis配置 * * @author guer */ -@Component -@ConfigurationProperties(prefix = "sms.verification-code.repository.redis") +@Data +@ConfigurationProperties(prefix = RedisProperties.PREFIX) public class RedisProperties { + public static final String PREFIX = "sms.verification-code.repository.redis"; + /** * Key前缀 */ private String keyPrefix; - - /** - * 获取Key前缀 - * - * @return Key前缀 - */ - public String getKeyPrefix() { - return keyPrefix; - } - - /** - * 设置Key前缀 - * - * @param keyPrefix Key前缀 - */ - public void setKeyPrefix(String keyPrefix) { - this.keyPrefix = keyPrefix; - } } diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/controller/package-info.java b/guerlab-sms-redis-repository-starter/src/main/java/net/guerlab/sms/server/spring/redis/properties/package-info.java similarity index 90% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/controller/package-info.java rename to guerlab-sms-redis-repository-starter/src/main/java/net/guerlab/sms/server/spring/redis/properties/package-info.java index 8f890c6353df39398eadb3b73fd0ef01c9b3a54b..f8e44e343ccd0271c070469d57fea062078c9214 100644 --- a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/controller/package-info.java +++ b/guerlab-sms-redis-repository-starter/src/main/java/net/guerlab/sms/server/spring/redis/properties/package-info.java @@ -15,6 +15,6 @@ * @author guer */ @NonNullApi -package net.guerlab.sms.server.controller; +package net.guerlab.sms.server.spring.redis.properties; import org.springframework.lang.NonNullApi; diff --git a/guerlab-sms-redis-repository-starter/src/main/java/net/guerlab/sms/server/repository/VerificationCodeRedisRepository.java b/guerlab-sms-redis-repository-starter/src/main/java/net/guerlab/sms/server/spring/redis/repository/VerificationCodeRedisRepository.java similarity index 82% rename from guerlab-sms-redis-repository-starter/src/main/java/net/guerlab/sms/server/repository/VerificationCodeRedisRepository.java rename to guerlab-sms-redis-repository-starter/src/main/java/net/guerlab/sms/server/spring/redis/repository/VerificationCodeRedisRepository.java index 5704572e30e9ff6af2ee14b9155b3aacd7d4ec27..a3f871377dd711d8cd87d2442a76b30dc7bc730e 100644 --- a/guerlab-sms-redis-repository-starter/src/main/java/net/guerlab/sms/server/repository/VerificationCodeRedisRepository.java +++ b/guerlab-sms-redis-repository-starter/src/main/java/net/guerlab/sms/server/spring/redis/repository/VerificationCodeRedisRepository.java @@ -10,19 +10,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package net.guerlab.sms.server.repository; +package net.guerlab.sms.server.spring.redis.repository; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; import net.guerlab.sms.core.utils.StringUtils; import net.guerlab.sms.server.entity.VerificationCode; -import net.guerlab.sms.server.properties.RedisProperties; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.context.properties.EnableConfigurationProperties; +import net.guerlab.sms.server.repository.VerificationCodeRepository; +import net.guerlab.sms.server.spring.redis.properties.RedisProperties; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.ValueOperations; import org.springframework.lang.Nullable; -import org.springframework.stereotype.Repository; import java.time.LocalDateTime; import java.time.ZoneOffset; @@ -34,28 +32,18 @@ import java.util.concurrent.TimeUnit; * @author guer */ @Slf4j -@Repository -@EnableConfigurationProperties(RedisProperties.class) public class VerificationCodeRedisRepository implements VerificationCodeRepository { - private RedisProperties properties; + private final RedisProperties properties; - private RedisTemplate redisTemplate; + private final RedisTemplate redisTemplate; - private ObjectMapper objectMapper; + private final ObjectMapper objectMapper; - @Autowired - public void setProperties(RedisProperties properties) { + public VerificationCodeRedisRepository(RedisProperties properties, RedisTemplate redisTemplate, + ObjectMapper objectMapper) { this.properties = properties; - } - - @Autowired - public void setRedisTemplate(RedisTemplate redisTemplate) { this.redisTemplate = redisTemplate; - } - - @Autowired - public void setObjectMapper(ObjectMapper objectMapper) { this.objectMapper = objectMapper; } diff --git a/guerlab-sms-redis-repository-starter/src/main/java/net/guerlab/sms/server/spring/redis/repository/package-info.java b/guerlab-sms-redis-repository-starter/src/main/java/net/guerlab/sms/server/spring/redis/repository/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..a295cb4d492f8d1b8eb8a34ecfb868ed369171a5 --- /dev/null +++ b/guerlab-sms-redis-repository-starter/src/main/java/net/guerlab/sms/server/spring/redis/repository/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2018-2021 guerlab.net and other contributors. + * + * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.gnu.org/licenses/lgpl-3.0.html + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @author guer + */ +@NonNullApi +package net.guerlab.sms.server.spring.redis.repository; + +import org.springframework.lang.NonNullApi; diff --git a/guerlab-sms-redis-repository-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/guerlab-sms-redis-repository-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 77400c57e39ebc5a8110c398451cfca3c1a35747..c348fa37affa685801117d691886604514a5d1d4 100644 --- a/guerlab-sms-redis-repository-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/guerlab-sms-redis-repository-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -2,8 +2,8 @@ "groups": [ { "name": "sms.verification-code.repository.redis", - "type": "net.guerlab.sms.server.properties.RedisProperties", - "sourceType": "net.guerlab.sms.server.properties.RedisProperties", + "type": "net.guerlab.sms.server.spring.redis.properties.RedisProperties", + "sourceType": "net.guerlab.sms.server.spring.redis.properties.RedisProperties", "description": "Redis配置." } ], @@ -11,7 +11,7 @@ { "name": "sms.verification-code.repository.redis.key-prefix", "type": "java.lang.String", - "sourceType": "net.guerlab.sms.server.properties.RedisProperties", + "sourceType": "net.guerlab.sms.server.spring.redis.properties.RedisProperties", "description": "Key前缀." } ] diff --git a/guerlab-sms-redis-repository-starter/src/main/resources/META-INF/spring.factories b/guerlab-sms-redis-repository-starter/src/main/resources/META-INF/spring.factories index 7beff44e5632a252294d803ab907ef325ec2088b..3c38f87b26aeee8a15105ce472cd224cc20ed969 100644 --- a/guerlab-sms-redis-repository-starter/src/main/resources/META-INF/spring.factories +++ b/guerlab-sms-redis-repository-starter/src/main/resources/META-INF/spring.factories @@ -1,2 +1,2 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -net.guerlab.sms.server.repository.VerificationCodeRedisRepository \ No newline at end of file +net.guerlab.sms.server.spring.redis.autoconfigure.VerificationCodeRedisRepositoryAutoConfiguration diff --git a/guerlab-sms-server-starter/pom.xml b/guerlab-sms-server-starter/pom.xml index 7a36b9913ba3b958d9049262b7f0a23c87deadfa..cc95efaaa5daf2399c3d2ce4a3ff75d670464e2b 100644 --- a/guerlab-sms-server-starter/pom.xml +++ b/guerlab-sms-server-starter/pom.xml @@ -17,16 +17,7 @@ net.guerlab.sms - guerlab-sms-core - - - - org.springframework.boot - spring-boot-starter-web - - - net.guerlab.loadbalancer - guerlab-loadbalancer + guerlab-sms-server diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/autoconfigure/SmsConfiguration.java b/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/autoconfigure/SmsConfiguration.java deleted file mode 100644 index 267a8c429af02ab1b0827ccdd21b0b77f5d9d7b5..0000000000000000000000000000000000000000 --- a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/autoconfigure/SmsConfiguration.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright 2018-2022 the original author or authors. - * - * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.gnu.org/licenses/lgpl-3.0.html - * - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.guerlab.sms.server.autoconfigure; - -import net.guerlab.sms.core.domain.NoticeInfo; -import net.guerlab.sms.core.domain.VerifyInfo; -import net.guerlab.sms.core.utils.StringUtils; -import net.guerlab.sms.server.controller.SmsController; -import net.guerlab.sms.server.loadbalancer.*; -import net.guerlab.sms.server.properties.*; -import net.guerlab.sms.server.repository.VerificationCodeMemoryRepository; -import net.guerlab.sms.server.repository.VerificationCodeRepository; -import net.guerlab.sms.server.service.DefaultSendAsyncThreadPoolExecutor; -import net.guerlab.sms.server.service.SendAsyncThreadPoolExecutor; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.servlet.mvc.method.RequestMappingInfo; -import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; - -import java.lang.reflect.Method; - -/** - * 短信服务配置 - * - * @author guer - * - */ -@Configuration -@EnableConfigurationProperties({ SmsAsyncProperties.class, SmsProperties.class, SmsWebProperties.class, - VerificationCodeProperties.class, VerificationCodeMemoryRepositoryProperties.class }) -@ComponentScan({ "net.guerlab.sms.server.controller", "net.guerlab.sms.server.repository", - "net.guerlab.sms.server.service" }) -public class SmsConfiguration { - - private static String getBasePath(SmsWebProperties properties) { - String bathPath = StringUtils.trimToNull(properties.getBasePath()); - - return bathPath == null ? SmsWebProperties.DEFAULT_BASE_PATH : bathPath; - } - - /** - * 构造发送者负载均衡器 - * - * @param properties - * 短信配置 - * @return 发送者负载均衡器 - */ - @Bean - @ConditionalOnMissingBean(SmsSenderLoadBalancer.class) - public SmsSenderLoadBalancer smsSenderLoadBalancer(SmsProperties properties) { - String type = properties.getLoadBalancerType(); - if (type == null) { - return new RandomSmsLoadBalancer(); - } - - type = type.trim(); - - if (RoundRobinSmsLoadBalancer.TYPE_NAME.equalsIgnoreCase(type)) { - return new RoundRobinSmsLoadBalancer(); - } else if (WeightRandomSmsLoadBalancer.TYPE_NAME.equalsIgnoreCase(type)) { - return new WeightRandomSmsLoadBalancer(); - } else if (WeightRoundRobinSmsLoadBalancer.TYPE_NAME.equalsIgnoreCase(type)) { - return new WeightRoundRobinSmsLoadBalancer(); - } else { - return new RandomSmsLoadBalancer(); - } - } - - /** - * 设置控制器映射 - * - * @param mapping - * RequestMappingHandlerMapping - * @param properties - * 短信Web配置 - * @param controller - * 短信Controller - * @throws NoSuchMethodException - * if a matching method is not found - * or if the name is "<init>"or "<clinit>". - * @throws SecurityException - * If a security manager, s, is present and - * the caller's class loader is not the same as or an - * ancestor of the class loader for the current class and - * invocation of {@link SecurityManager#checkPackageAccess - * s.checkPackageAccess()} denies access to the package - * of this class. - */ - @Autowired(required = false) - @ConditionalOnBean(RequestMappingHandlerMapping.class) - public void setWebMapping(RequestMappingHandlerMapping mapping, SmsWebProperties properties, - SmsController controller) throws NoSuchMethodException, SecurityException { - if (!properties.isEnable()) { - return; - } - - String bathPath = getBasePath(properties); - - if (properties.isEnableSend()) { - Method sendMethod = SmsController.class.getMethod("sendVerificationCode", String.class); - RequestMappingInfo sendInfo = RequestMappingInfo.paths(bathPath + "/verificationCode/{phone}") - .methods(RequestMethod.POST).build(); - mapping.registerMapping(sendInfo, controller, sendMethod); - } - if (properties.isEnableGet()) { - Method getMethod = SmsController.class.getMethod("getVerificationCode", String.class, String.class); - RequestMappingInfo getInfo = RequestMappingInfo.paths(bathPath + "/verificationCode/{phone}") - .methods(RequestMethod.GET).produces("application/json").build(); - mapping.registerMapping(getInfo, controller, getMethod); - } - if (properties.isEnableVerify()) { - Method verifyMethod = SmsController.class.getMethod("verifyVerificationCode", VerifyInfo.class); - RequestMappingInfo verifyInfo = RequestMappingInfo.paths(bathPath + "/verificationCode") - .methods(RequestMethod.POST).build(); - mapping.registerMapping(verifyInfo, controller, verifyMethod); - } - if (properties.isEnableNotice()) { - Method noticeMethod = SmsController.class.getMethod("sendNotice", NoticeInfo.class); - RequestMappingInfo noticeInfo = RequestMappingInfo.paths(bathPath + "/notice").methods(RequestMethod.PUT) - .build(); - mapping.registerMapping(noticeInfo, controller, noticeMethod); - } - } - - /** - * 构造默认验证码储存接口实现 - * - * @param properties - * 验证码内存储存配置 - * @return 默认验证码储存接口实现 - */ - @Bean - @ConditionalOnMissingBean(VerificationCodeRepository.class) - public VerificationCodeRepository verificationCodeMemoryRepository( - VerificationCodeMemoryRepositoryProperties properties) { - VerificationCodeMemoryRepository repository = new VerificationCodeMemoryRepository(); - repository.setProperties(properties); - return repository; - } - - /** - * 构造发送异步处理线程池 - * - * @param properties - * 短信异步配置 - * @return 发送异步处理线程池 - */ - @Bean - @ConditionalOnProperty(name = "sms.async.enable", havingValue = "true") - @ConditionalOnMissingBean - public SendAsyncThreadPoolExecutor sendAsyncThreadPoolExecutor(SmsAsyncProperties properties) { - return new DefaultSendAsyncThreadPoolExecutor(properties); - } - - /** - * 创建RestTemplate - * - * @return RestTemplate - */ - @Bean - @ConditionalOnMissingBean - public RestTemplate restTemplate() { - return new RestTemplate(); - } -} diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/spring/autoconfigure/SmsAutoConfiguration.java b/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/spring/autoconfigure/SmsAutoConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..d14761b6b6186b80b290ff7c195d224d744e1499 --- /dev/null +++ b/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/spring/autoconfigure/SmsAutoConfiguration.java @@ -0,0 +1,104 @@ +/* + * Copyright 2018-2022 the original author or authors. + * + * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.gnu.org/licenses/lgpl-3.0.html + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.guerlab.sms.server.spring.autoconfigure; + +import net.guerlab.loadbalancer.ILoadBalancer; +import net.guerlab.sms.core.domain.NoticeData; +import net.guerlab.sms.core.handler.SendHandler; +import net.guerlab.sms.server.loadbalancer.*; +import net.guerlab.sms.server.properties.SmsConfig; +import net.guerlab.sms.server.service.DefaultNoticeService; +import net.guerlab.sms.server.service.DefaultSendAsyncThreadPoolExecutor; +import net.guerlab.sms.server.service.NoticeService; +import net.guerlab.sms.server.service.SendAsyncThreadPoolExecutor; +import net.guerlab.sms.server.spring.properties.SmsAsyncProperties; +import net.guerlab.sms.server.spring.properties.SmsProperties; +import org.springframework.beans.factory.ObjectProvider; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.client.RestTemplate; + +/** + * 短信服务配置 + * + * @author guer + */ +@Configuration +@EnableConfigurationProperties({ SmsProperties.class, SmsAsyncProperties.class }) +public class SmsAutoConfiguration { + + @Bean + @ConditionalOnMissingBean(NoticeService.class) + public NoticeService noticeService(SmsProperties properties, SmsAsyncProperties asyncProperties, + ILoadBalancer smsSenderLoadbalancer, + ObjectProvider executorProvider) { + return new DefaultNoticeService(properties, asyncProperties, smsSenderLoadbalancer, + executorProvider.getIfUnique()); + } + + /** + * 构造发送异步处理线程池 + * + * @param properties + * 短信异步配置 + * @return 发送异步处理线程池 + */ + @Bean + @ConditionalOnMissingBean + @ConditionalOnProperty(prefix = SmsAsyncProperties.PREFIX, name = "enable", havingValue = "true") + public SendAsyncThreadPoolExecutor sendAsyncThreadPoolExecutor(SmsAsyncProperties properties) { + return new DefaultSendAsyncThreadPoolExecutor(properties); + } + + /** + * 构造发送者负载均衡器 + * + * @param properties + * 短信配置 + * @return 发送者负载均衡器 + */ + @Bean + @ConditionalOnMissingBean(SmsSenderLoadBalancer.class) + public SmsSenderLoadBalancer smsSenderLoadBalancer(SmsConfig properties) { + String type = properties.getLoadBalancerType(); + if (type == null) { + return new RandomSmsLoadBalancer(); + } + + type = type.trim(); + + if (RoundRobinSmsLoadBalancer.TYPE_NAME.equalsIgnoreCase(type)) { + return new RoundRobinSmsLoadBalancer(); + } else if (WeightRandomSmsLoadBalancer.TYPE_NAME.equalsIgnoreCase(type)) { + return new WeightRandomSmsLoadBalancer(); + } else if (WeightRoundRobinSmsLoadBalancer.TYPE_NAME.equalsIgnoreCase(type)) { + return new WeightRoundRobinSmsLoadBalancer(); + } else { + return new RandomSmsLoadBalancer(); + } + } + + /** + * 创建RestTemplate + * + * @return RestTemplate + */ + @Bean + @ConditionalOnMissingBean + public RestTemplate restTemplate() { + return new RestTemplate(); + } +} diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/spring/autoconfigure/VerificationCodeAutoConfiguration.java b/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/spring/autoconfigure/VerificationCodeAutoConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..84eaf5d78c5058d5be36e764900dd4777f8ad32f --- /dev/null +++ b/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/spring/autoconfigure/VerificationCodeAutoConfiguration.java @@ -0,0 +1,89 @@ +/* + * Copyright 2018-2022 the original author or authors. + * + * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.gnu.org/licenses/lgpl-3.0.html + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.guerlab.sms.server.spring.autoconfigure; + +import net.guerlab.sms.server.properties.VerificationCodeConfig; +import net.guerlab.sms.server.repository.VerificationCodeMemoryRepository; +import net.guerlab.sms.server.repository.VerificationCodeRepository; +import net.guerlab.sms.server.service.*; +import net.guerlab.sms.server.spring.properties.VerificationCodeMemoryRepositoryProperties; +import net.guerlab.sms.server.spring.properties.VerificationCodeProperties; +import org.springframework.beans.factory.ObjectProvider; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * 验证码服务配置 + * + * @author guer + */ +@Configuration +@AutoConfigureAfter(SmsAutoConfiguration.class) +@EnableConfigurationProperties({ VerificationCodeProperties.class, VerificationCodeMemoryRepositoryProperties.class }) +public class VerificationCodeAutoConfiguration { + + /** + * 创建默认验证码生成 + * + * @param properties + * 验证码配置 + * @return 默认验证码生成 + */ + @Bean + @ConditionalOnMissingBean(CodeGenerate.class) + public CodeGenerate defaultCodeGenerate(VerificationCodeConfig properties) { + return new DefaultCodeGenerate(properties); + } + + /** + * 创建手机验证码服务 + * + * @param repository + * 验证码储存接口 + * @param properties + * 验证码配置 + * @param noticeService + * 短信通知服务 + * @param codeGenerate + * 验证码生成 + * @param verificationCodeTypeGenerateProvider + * 验证码类型生成 + * @return 手机验证码服务 + */ + @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") + @Bean + @ConditionalOnMissingBean(VerificationCodeService.class) + public VerificationCodeService verificationCodeService(VerificationCodeRepository repository, + VerificationCodeConfig properties, NoticeService noticeService, CodeGenerate codeGenerate, + ObjectProvider verificationCodeTypeGenerateProvider) { + return new DefaultVerificationCodeService(repository, properties, noticeService, codeGenerate, + verificationCodeTypeGenerateProvider.getIfUnique()); + } + + /** + * 构造默认验证码储存接口实现 + * + * @param config + * 验证码内存储存配置 + * @return 默认验证码储存接口实现 + */ + @Bean + @ConditionalOnMissingBean(VerificationCodeRepository.class) + public VerificationCodeRepository verificationCodeMemoryRepository( + VerificationCodeMemoryRepositoryProperties config) { + return new VerificationCodeMemoryRepository(config); + } +} diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/autoconfigure/package-info.java b/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/spring/autoconfigure/package-info.java similarity index 90% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/autoconfigure/package-info.java rename to guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/spring/autoconfigure/package-info.java index bfaebe435f0bfeefdbda915041ed0c091318ba46..9c0f746aed1b0fde94a2a187267f412ef4b48f93 100644 --- a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/autoconfigure/package-info.java +++ b/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/spring/autoconfigure/package-info.java @@ -15,6 +15,6 @@ * @author guer */ @NonNullApi -package net.guerlab.sms.server.autoconfigure; +package net.guerlab.sms.server.spring.autoconfigure; import org.springframework.lang.NonNullApi; diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/spring/properties/SmsAsyncProperties.java b/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/spring/properties/SmsAsyncProperties.java new file mode 100644 index 0000000000000000000000000000000000000000..670ff1845e45c20e55f055339b780e8bf9e94d81 --- /dev/null +++ b/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/spring/properties/SmsAsyncProperties.java @@ -0,0 +1,27 @@ +/* + * Copyright 2018-2022 the original author or authors. + * + * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.gnu.org/licenses/lgpl-3.0.html + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.guerlab.sms.server.spring.properties; + +import net.guerlab.sms.server.properties.SmsAsyncConfig; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * 短信异步配置 + * + * @author guer + */ +@ConfigurationProperties(prefix = SmsAsyncProperties.PREFIX) +public class SmsAsyncProperties extends SmsAsyncConfig { + + public static final String PREFIX = "sms.async"; +} diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/spring/properties/SmsProperties.java b/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/spring/properties/SmsProperties.java new file mode 100644 index 0000000000000000000000000000000000000000..f1dbb2a79ecaf21068fe18cdf3b152c40c10a577 --- /dev/null +++ b/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/spring/properties/SmsProperties.java @@ -0,0 +1,27 @@ +/* + * Copyright 2018-2022 the original author or authors. + * + * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.gnu.org/licenses/lgpl-3.0.html + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.guerlab.sms.server.spring.properties; + +import net.guerlab.sms.server.properties.SmsConfig; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * 短信配置 + * + * @author guer + */ +@ConfigurationProperties(prefix = SmsProperties.PREFIX) +public class SmsProperties extends SmsConfig { + + public static final String PREFIX = "sms"; +} diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/spring/properties/VerificationCodeMemoryRepositoryProperties.java b/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/spring/properties/VerificationCodeMemoryRepositoryProperties.java new file mode 100644 index 0000000000000000000000000000000000000000..4a76fe8363a88d7df8e4db2864cf930807086863 --- /dev/null +++ b/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/spring/properties/VerificationCodeMemoryRepositoryProperties.java @@ -0,0 +1,27 @@ +/* + * Copyright 2018-2022 the original author or authors. + * + * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.gnu.org/licenses/lgpl-3.0.html + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.guerlab.sms.server.spring.properties; + +import net.guerlab.sms.server.properties.VerificationCodeMemoryRepositoryConfig; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * 验证码内存储存配置 + * + * @author guer + */ +@ConfigurationProperties(prefix = VerificationCodeMemoryRepositoryProperties.PREFIX) +public class VerificationCodeMemoryRepositoryProperties extends VerificationCodeMemoryRepositoryConfig { + + public static final String PREFIX = "sms.verification-code.repository.memory"; +} diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/spring/properties/VerificationCodeProperties.java b/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/spring/properties/VerificationCodeProperties.java new file mode 100644 index 0000000000000000000000000000000000000000..1338abba61b60f02d31de8076ff2e598470feccd --- /dev/null +++ b/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/spring/properties/VerificationCodeProperties.java @@ -0,0 +1,27 @@ +/* + * Copyright 2018-2022 the original author or authors. + * + * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.gnu.org/licenses/lgpl-3.0.html + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.guerlab.sms.server.spring.properties; + +import net.guerlab.sms.server.properties.VerificationCodeConfig; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * 验证码配置 + * + * @author guer + */ +@ConfigurationProperties(prefix = VerificationCodeProperties.PREFIX) +public class VerificationCodeProperties extends VerificationCodeConfig { + + public static final String PREFIX = "sms.verification-code"; +} diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/repository/package-info.java b/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/spring/properties/package-info.java similarity index 91% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/repository/package-info.java rename to guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/spring/properties/package-info.java index 6ebe54fde0969a528c22615f9e8264cd2e4853b5..d3c1a88f46c446d1b2bd986ebac5f4b3c370c183 100644 --- a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/repository/package-info.java +++ b/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/spring/properties/package-info.java @@ -15,6 +15,6 @@ * @author guer */ @NonNullApi -package net.guerlab.sms.server.repository; +package net.guerlab.sms.server.spring.properties; import org.springframework.lang.NonNullApi; diff --git a/guerlab-sms-server-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/guerlab-sms-server-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 1a373b094a64587e0673b1e210d8c89a5b7c84b2..1733183776ed365e78039dbc4698191d3e947894 100644 --- a/guerlab-sms-server-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/guerlab-sms-server-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -2,32 +2,26 @@ "groups": [ { "name": "sms", - "type": "net.guerlab.sms.server.properties.SmsProperties", - "sourceType": "net.guerlab.sms.server.properties.SmsProperties", + "type": "net.guerlab.sms.server.spring.properties.SmsProperties", + "sourceType": "net.guerlab.sms.server.spring.properties.SmsProperties", "description": "短信配置." }, - { - "name": "sms.web", - "type": "net.guerlab.sms.server.properties.SmsWebProperties", - "sourceType": "net.guerlab.sms.server.properties.SmsWebProperties", - "description": "短信Web配置." - }, { "name": "sms.verification-code", - "type": "net.guerlab.sms.server.properties.VerificationCodeProperties", - "sourceType": "net.guerlab.sms.server.properties.VerificationCodeProperties", + "type": "net.guerlab.sms.server.spring.properties.VerificationCodeProperties", + "sourceType": "net.guerlab.sms.server.spring.properties.VerificationCodeProperties", "description": "短信验证码配置." }, { "name": "sms.verification-code.repository.memory", - "type": "net.guerlab.sms.server.properties.VerificationCodeMemoryRepositoryProperties", - "sourceType": "net.guerlab.sms.server.properties.VerificationCodeMemoryRepositoryProperties", + "type": "net.guerlab.sms.server.spring.properties.VerificationCodeMemoryRepositoryProperties", + "sourceType": "net.guerlab.sms.server.spring.properties.VerificationCodeMemoryRepositoryProperties", "description": "验证码内存储存配置." }, { "name": "sms.async", - "type": "net.guerlab.sms.server.properties.SmsAsyncProperties", - "sourceType": "net.guerlab.sms.server.properties.SmsAsyncProperties", + "type": "net.guerlab.sms.server.spring.properties.SmsAsyncProperties", + "sourceType": "net.guerlab.sms.server.spring.properties.SmsAsyncProperties", "description": "短信异步配置." } ], @@ -35,172 +29,130 @@ { "name": "sms.reg", "type": "java.lang.String", - "sourceType": "net.guerlab.sms.server.properties.SmsProperties", + "sourceType": "net.guerlab.sms.server.spring.properties.SmsProperties", "description": "手机号码正则规则." }, { "name": "sms.load-balancer-type", "type": "java.lang.String", - "sourceType": "net.guerlab.sms.server.properties.SmsProperties", + "sourceType": "net.guerlab.sms.server.spring.properties.SmsProperties", "description": "负载均衡类型.可选值:Random、RoundRobin、WeightRandom、WeightRoundRobin.", "defaultValue": "Random" }, - { - "name": "sms.web.enable", - "type": "java.lang.Boolean", - "sourceType": "net.guerlab.sms.server.properties.SmsWebProperties", - "description": "是否启用web端点.", - "defaultValue": "false" - }, - { - "name": "sms.web.base-path", - "type": "java.lang.String", - "sourceType": "net.guerlab.sms.server.properties.SmsWebProperties", - "description": "基础路径.", - "defaultValue": "/sms" - }, - { - "name": "sms.web.enable-send", - "type": "java.lang.Boolean", - "sourceType": "net.guerlab.sms.server.properties.SmsWebProperties", - "description": "是否启用验证码发送web端点.", - "defaultValue": "true" - }, - { - "name": "sms.web.enable-get", - "type": "java.lang.Boolean", - "sourceType": "net.guerlab.sms.server.properties.SmsWebProperties", - "description": "是否启用验证码查询web端点.", - "defaultValue": "true" - }, - { - "name": "sms.web.enable-verify", - "type": "java.lang.Boolean", - "sourceType": "net.guerlab.sms.server.properties.SmsWebProperties", - "description": "是否启用验证码验证web端点.", - "defaultValue": "true" - }, - { - "name": "sms.web.enable-notice", - "type": "java.lang.Boolean", - "sourceType": "net.guerlab.sms.server.properties.SmsWebProperties", - "description": "是否启用通知发送web端点.", - "defaultValue": "true" - }, { "name": "sms.verification-code.type", "type": "java.lang.String", - "sourceType": "net.guerlab.sms.server.properties.VerificationCodeProperties", + "sourceType": "net.guerlab.sms.server.spring.properties.VerificationCodeProperties", "description": "验证码业务所使用的类型.", "defaultValue": "VerificationCode" }, { "name": "sms.verification-code.expiration-time", "type": "java.lang.Long", - "sourceType": "net.guerlab.sms.server.properties.VerificationCodeProperties", + "sourceType": "net.guerlab.sms.server.spring.properties.VerificationCodeProperties", "description": "验证码过期时间,小于等于0表示不过期,单位秒." }, { "name": "sms.verification-code.retry-interval-time", "type": "java.lang.Long", - "sourceType": "net.guerlab.sms.server.properties.VerificationCodeProperties", + "sourceType": "net.guerlab.sms.server.spring.properties.VerificationCodeProperties", "description": "重新发送验证码间隔时间,小于等于0表示不启用,单位秒." }, { "name": "sms.verification-code.use-identification-code", "type": "java.lang.Boolean", - "sourceType": "net.guerlab.sms.server.properties.VerificationCodeProperties", + "sourceType": "net.guerlab.sms.server.spring.properties.VerificationCodeProperties", "description": "是否使用识别码.", "defaultValue": "false" }, { "name": "sms.verification-code.code-length", "type": "java.lang.Integer", - "sourceType": "net.guerlab.sms.server.properties.VerificationCodeProperties", + "sourceType": "net.guerlab.sms.server.spring.properties.VerificationCodeProperties", "description": "验证码长度.", "defaultValue": "6" }, { "name": "sms.verification-code.identification-code-length", "type": "java.lang.Integer", - "sourceType": "net.guerlab.sms.server.properties.VerificationCodeProperties", + "sourceType": "net.guerlab.sms.server.spring.properties.VerificationCodeProperties", "description": "识别码长度.", "defaultValue": "3" }, { "name": "sms.verification-code.delete-by-verify-succeed", "type": "java.lang.Boolean", - "sourceType": "net.guerlab.sms.server.properties.VerificationCodeProperties", + "sourceType": "net.guerlab.sms.server.spring.properties.VerificationCodeProperties", "description": "验证成功是否删除验证码.", "defaultValue": "true" }, { "name": "sms.verification-code.delete-by-verify-fail", "type": "java.lang.Boolean", - "sourceType": "net.guerlab.sms.server.properties.VerificationCodeProperties", + "sourceType": "net.guerlab.sms.server.spring.properties.VerificationCodeProperties", "description": "验证失败是否删除验证码.", "defaultValue": "false" }, { "name": "sms.verification-code.template-has-expiration-time", "type": "java.lang.Boolean", - "sourceType": "net.guerlab.sms.server.properties.VerificationCodeProperties", + "sourceType": "net.guerlab.sms.server.spring.properties.VerificationCodeProperties", "description": "模板中是否包含过期时间.", "defaultValue": "false" }, { "name": "sms.verification-code.repository.memory.gc-frequency", "type": "java.lang.Long", - "sourceType": "net.guerlab.sms.server.properties.VerificationCodeMemoryRepositoryProperties", + "sourceType": "net.guerlab.sms.server.spring.properties.VerificationCodeMemoryRepositoryProperties", "description": "gc频率,单位秒.", "defaultValue": "300" }, { "name": "sms.async.enable", "type": "java.lang.Boolean", - "sourceType": "net.guerlab.sms.server.properties.SmsAsyncProperties", + "sourceType": "net.guerlab.sms.server.spring.properties.SmsAsyncProperties", "description": "是否启用异步支持.", "defaultValue": "true" }, { "name": "sms.async.core-pool-size", "type": "java.lang.Integer", - "sourceType": "net.guerlab.sms.server.properties.SmsAsyncProperties", + "sourceType": "net.guerlab.sms.server.spring.properties.SmsAsyncProperties", "description": "核心线程数量.", "defaultValue": "可用处理器数量 (Runtime.getRuntime().availableProcessors())" }, { "name": "sms.async.maximum-pool-size", "type": "java.lang.Integer", - "sourceType": "net.guerlab.sms.server.properties.SmsAsyncProperties", + "sourceType": "net.guerlab.sms.server.spring.properties.SmsAsyncProperties", "description": "最大线程数量.", "defaultValue": "可用处理器数量 * 2 (Runtime.getRuntime().availableProcessors() * 2)" }, { "name": "sms.async.keep-alive-time", "type": "java.lang.Long", - "sourceType": "net.guerlab.sms.server.properties.SmsAsyncProperties", + "sourceType": "net.guerlab.sms.server.spring.properties.SmsAsyncProperties", "description": "线程最大空闲时间.", "defaultValue": "60" }, { "name": "sms.async.unit", "type": "java.util.concurrent.TimeUnit", - "sourceType": "net.guerlab.sms.server.properties.SmsAsyncProperties", + "sourceType": "net.guerlab.sms.server.spring.properties.SmsAsyncProperties", "description": "线程最大空闲时间单位.", "defaultValue": "SECONDS" }, { "name": "sms.async.queue-capacity", "type": "java.lang.Integer", - "sourceType": "net.guerlab.sms.server.properties.SmsAsyncProperties", + "sourceType": "net.guerlab.sms.server.spring.properties.SmsAsyncProperties", "description": "队列容量.", "defaultValue": "Integer.MAX_VALUE" }, { "name": "sms.async.reject-policy", "type": "net.guerlab.sms.server.properties.RejectPolicy", - "sourceType": "net.guerlab.sms.server.properties.SmsAsyncProperties", + "sourceType": "net.guerlab.sms.server.spring.properties.SmsAsyncProperties", "description": "拒绝策略, 可选值:Abort、Caller、Discard、DiscardOldest.", "defaultValue": "Abort" } diff --git a/guerlab-sms-server-starter/src/main/resources/META-INF/spring.factories b/guerlab-sms-server-starter/src/main/resources/META-INF/spring.factories index a5948e41b48206063d010f853846f1628bdb3571..0ea9a28a13b82caf135ac8e9bc8be30dfab2c5fa 100644 --- a/guerlab-sms-server-starter/src/main/resources/META-INF/spring.factories +++ b/guerlab-sms-server-starter/src/main/resources/META-INF/spring.factories @@ -1,2 +1,3 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -net.guerlab.sms.server.autoconfigure.SmsConfiguration +net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration,\ +net.guerlab.sms.server.spring.autoconfigure.VerificationCodeAutoConfiguration diff --git a/guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/AsyncPropertiesTest.java b/guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/spring/AsyncPropertiesTest.java similarity index 70% rename from guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/AsyncPropertiesTest.java rename to guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/spring/AsyncPropertiesTest.java index f4761c1723727c93bda5897535e905ab116ab492..70434639569beaafe10de74c04f448d465252f8b 100644 --- a/guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/AsyncPropertiesTest.java +++ b/guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/spring/AsyncPropertiesTest.java @@ -10,11 +10,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package net.guerlab.sms.server; +package net.guerlab.sms.server.spring; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.properties.RejectPolicy; -import net.guerlab.sms.server.properties.SmsAsyncProperties; +import net.guerlab.sms.server.properties.SmsAsyncConfig; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -37,6 +37,7 @@ public class AsyncPropertiesTest { @Before public void setUp() { context = new AnnotationConfigApplicationContext(); + context.register(SmsAutoConfiguration.class); } @After @@ -47,61 +48,54 @@ public class AsyncPropertiesTest { @Test public void enableWithTrue() { TestPropertyValues.of("sms.async.enable=true").applyTo(context); - context.register(SmsConfiguration.class); context.refresh(); - SmsAsyncProperties properties = context.getBean(SmsAsyncProperties.class); + SmsAsyncConfig properties = context.getBean(SmsAsyncConfig.class); Assert.assertTrue(properties.isEnable()); } @Test public void enableWithFalse() { TestPropertyValues.of("sms.async.enable=false").applyTo(context); - context.register(SmsConfiguration.class); context.refresh(); - SmsAsyncProperties properties = context.getBean(SmsAsyncProperties.class); + SmsAsyncConfig properties = context.getBean(SmsAsyncConfig.class); Assert.assertFalse(properties.isEnable()); } @Test public void defaultUnit() { - context.register(SmsConfiguration.class); context.refresh(); - SmsAsyncProperties properties = context.getBean(SmsAsyncProperties.class); + SmsAsyncConfig properties = context.getBean(SmsAsyncConfig.class); Assert.assertEquals(properties.getUnit(), TimeUnit.SECONDS); } @Test public void customerUnit() { TestPropertyValues.of("sms.async.unit=MINUTES").applyTo(context); - context.register(SmsConfiguration.class); context.refresh(); - SmsAsyncProperties properties = context.getBean(SmsAsyncProperties.class); + SmsAsyncConfig properties = context.getBean(SmsAsyncConfig.class); Assert.assertEquals(properties.getUnit(), TimeUnit.MINUTES); } @Test public void defaultRejectPolicy() { - context.register(SmsConfiguration.class); context.refresh(); - SmsAsyncProperties properties = context.getBean(SmsAsyncProperties.class); + SmsAsyncConfig properties = context.getBean(SmsAsyncConfig.class); Assert.assertEquals(properties.getRejectPolicy(), RejectPolicy.Abort); } @Test public void customerRejectPolicy() { TestPropertyValues.of("sms.async.reject-policy=Discard").applyTo(context); - context.register(SmsConfiguration.class); context.refresh(); - SmsAsyncProperties properties = context.getBean(SmsAsyncProperties.class); + SmsAsyncConfig properties = context.getBean(SmsAsyncConfig.class); Assert.assertEquals(properties.getRejectPolicy(), RejectPolicy.Discard); } @Test public void nullRejectPolicy() { TestPropertyValues.of("sms.async.reject-policy=").applyTo(context); - context.register(SmsConfiguration.class); context.refresh(); - SmsAsyncProperties properties = context.getBean(SmsAsyncProperties.class); + SmsAsyncConfig properties = context.getBean(SmsAsyncConfig.class); Assert.assertEquals(properties.getRejectPolicy(), RejectPolicy.Abort); } } diff --git a/guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/AsyncTest.java b/guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/spring/AsyncTest.java similarity index 95% rename from guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/AsyncTest.java rename to guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/spring/AsyncTest.java index 15cf4a541da2984e91b1f10c79f8bf099c315196..89c0dc1de2192289c1ae9f31aa63cecbb779bb29 100644 --- a/guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/AsyncTest.java +++ b/guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/spring/AsyncTest.java @@ -10,14 +10,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package net.guerlab.sms.server; +package net.guerlab.sms.server.spring; import lombok.extern.slf4j.Slf4j; import net.guerlab.sms.core.domain.NoticeData; import net.guerlab.sms.core.handler.SendHandler; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.loadbalancer.SmsSenderLoadBalancer; import net.guerlab.sms.server.service.NoticeService; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -50,7 +50,7 @@ public class AsyncTest { @Before public void setUp() { context = new AnnotationConfigApplicationContext(); - context.register(SmsConfiguration.class); + context.register(SmsAutoConfiguration.class); context.register(TestHandlerAutoConfigure.class); } diff --git a/guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/AutoConfigurationTest.java b/guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/spring/AutoConfigurationTest.java similarity index 89% rename from guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/AutoConfigurationTest.java rename to guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/spring/AutoConfigurationTest.java index 3fc9dfcfdd7385159d418e7eaa3f3b34e2848d70..3baee09516bc3d9a8d9ac9e6f40bbe72295e92cf 100644 --- a/guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/AutoConfigurationTest.java +++ b/guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/spring/AutoConfigurationTest.java @@ -10,14 +10,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package net.guerlab.sms.server; +package net.guerlab.sms.server.spring; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.loadbalancer.SmsSenderLoadBalancer; import net.guerlab.sms.server.repository.VerificationCodeRepository; import net.guerlab.sms.server.service.CodeGenerate; import net.guerlab.sms.server.service.SendAsyncThreadPoolExecutor; import net.guerlab.sms.server.service.VerificationCodeService; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; +import net.guerlab.sms.server.spring.autoconfigure.VerificationCodeAutoConfiguration; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -40,7 +41,8 @@ public class AutoConfigurationTest { @Before public void setUp() { context = new AnnotationConfigApplicationContext(); - context.register(SmsConfiguration.class); + context.register(SmsAutoConfiguration.class); + context.register(VerificationCodeAutoConfiguration.class); } @After diff --git a/guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/EventTest.java b/guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/spring/EventTest.java similarity index 95% rename from guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/EventTest.java rename to guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/spring/EventTest.java index 403fb8951a825e1123b1306b48438623f4ebe565..d4038739f983a5537619fe1ded3a91d9701a32f4 100644 --- a/guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/EventTest.java +++ b/guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/spring/EventTest.java @@ -1,14 +1,14 @@ -package net.guerlab.sms.server; +package net.guerlab.sms.server.spring; import lombok.extern.slf4j.Slf4j; import net.guerlab.sms.core.domain.NoticeData; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.entity.SmsSendFinallyEvent; import net.guerlab.sms.server.handler.AbstractSendHandler; import net.guerlab.sms.server.handler.SmsSendFinallyEventListener; import net.guerlab.sms.server.loadbalancer.SmsSenderLoadBalancer; import net.guerlab.sms.server.properties.AbstractHandlerProperties; import net.guerlab.sms.server.service.NoticeService; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -42,7 +42,7 @@ public class EventTest { @Before public void setUp() { context = new AnnotationConfigApplicationContext(); - context.register(SmsConfiguration.class); + context.register(SmsAutoConfiguration.class); context.register(TestAutoConfigure.class); context.register(TestSmsSendFinallyEventListener.class); context.refresh(); @@ -91,7 +91,7 @@ public class EventTest { @Configuration @EnableConfigurationProperties(TestProperties.class) - @AutoConfigureAfter(SmsConfiguration.class) + @AutoConfigureAfter(SmsAutoConfiguration.class) public static class TestAutoConfigure { @Bean diff --git a/guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/MultiKeyTest.java b/guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/spring/MultiKeyTest.java similarity index 94% rename from guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/MultiKeyTest.java rename to guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/spring/MultiKeyTest.java index 2050fe1ee7623447360f9c3474bd790e7f5618e0..02b46ab25b0dd9b2cfd484baaa218584e5f52f95 100644 --- a/guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/MultiKeyTest.java +++ b/guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/spring/MultiKeyTest.java @@ -10,14 +10,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package net.guerlab.sms.server; +package net.guerlab.sms.server.spring; import net.guerlab.sms.core.domain.NoticeData; import net.guerlab.sms.core.exception.NotFindSendHandlerException; import net.guerlab.sms.core.handler.SendHandler; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.loadbalancer.SmsSenderLoadBalancer; import net.guerlab.sms.server.service.NoticeService; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -43,7 +43,7 @@ public class MultiKeyTest { @Before public void setUp() { context = new AnnotationConfigApplicationContext(); - context.register(SmsConfiguration.class); + context.register(SmsAutoConfiguration.class); context.register(TestHandlerAutoConfigure.class); context.refresh(); } diff --git a/guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/VerificationCodeMemoryRepositoryTest.java b/guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/spring/VerificationCodeMemoryRepositoryTest.java similarity index 86% rename from guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/VerificationCodeMemoryRepositoryTest.java rename to guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/spring/VerificationCodeMemoryRepositoryTest.java index 3aa281ca01bb184d41efbd9bca2a63b516ac34ad..b8e346beabec2083b688fa7a3421dd1a6e6c1b43 100644 --- a/guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/VerificationCodeMemoryRepositoryTest.java +++ b/guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/spring/VerificationCodeMemoryRepositoryTest.java @@ -10,11 +10,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package net.guerlab.sms.server; +package net.guerlab.sms.server.spring; import lombok.extern.slf4j.Slf4j; import net.guerlab.sms.server.entity.VerificationCode; -import net.guerlab.sms.server.properties.VerificationCodeMemoryRepositoryProperties; +import net.guerlab.sms.server.properties.VerificationCodeMemoryRepositoryConfig; import net.guerlab.sms.server.repository.VerificationCodeMemoryRepository; import java.time.LocalDateTime; @@ -28,11 +28,10 @@ import java.util.concurrent.TimeUnit; public class VerificationCodeMemoryRepositoryTest { public static void main(String[] args) { - VerificationCodeMemoryRepositoryProperties properties = new VerificationCodeMemoryRepositoryProperties(); + VerificationCodeMemoryRepositoryConfig properties = new VerificationCodeMemoryRepositoryConfig(); properties.setGcFrequency(30L); - VerificationCodeMemoryRepository repository = new VerificationCodeMemoryRepository(); - repository.setProperties(properties); + VerificationCodeMemoryRepository repository = new VerificationCodeMemoryRepository(properties); ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1, r -> { Thread thread = new Thread(r); diff --git a/guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/package-info.java b/guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/spring/package-info.java similarity index 92% rename from guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/package-info.java rename to guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/spring/package-info.java index 861b1d27530e563177b07936142709934f5edceb..2f9bd9964b29479794e14c90cd3307f7143127f3 100644 --- a/guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/package-info.java +++ b/guerlab-sms-server-starter/src/test/java/net/guerlab/sms/server/spring/package-info.java @@ -15,6 +15,6 @@ * @author guer */ @NonNullApi -package net.guerlab.sms.server; +package net.guerlab.sms.server.spring; import org.springframework.lang.NonNullApi; diff --git a/guerlab-sms-server-webmvc-starter/pom.xml b/guerlab-sms-server-webmvc-starter/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..eac3083b26a5d2597c9f175b610a28db9efb1165 --- /dev/null +++ b/guerlab-sms-server-webmvc-starter/pom.xml @@ -0,0 +1,35 @@ + + 4.0.0 + guerlab-sms-server-webmvc-starter + + + net.guerlab.sms + guerlab-sms + ${revision} + + + + ${basedir}/.. + + + + + net.guerlab.sms + guerlab-sms-server-starter + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + org.springframework.boot + spring-boot-starter-test + test + + + diff --git a/guerlab-sms-server-webmvc-starter/src/main/java/net/guerlab/sms/server/spring/webmvc/autoconfigure/SmsWebmvcConfiguration.java b/guerlab-sms-server-webmvc-starter/src/main/java/net/guerlab/sms/server/spring/webmvc/autoconfigure/SmsWebmvcConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..262fe8b5bcb39bcae07fbe463f098fae812aebf7 --- /dev/null +++ b/guerlab-sms-server-webmvc-starter/src/main/java/net/guerlab/sms/server/spring/webmvc/autoconfigure/SmsWebmvcConfiguration.java @@ -0,0 +1,45 @@ +/* + * Copyright 2018-2022 the original author or authors. + * + * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.gnu.org/licenses/lgpl-3.0.html + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.guerlab.sms.server.spring.webmvc.autoconfigure; + +import lombok.extern.slf4j.Slf4j; +import net.guerlab.sms.server.service.NoticeService; +import net.guerlab.sms.server.service.VerificationCodeService; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; +import net.guerlab.sms.server.spring.webmvc.controller.SmsController; +import net.guerlab.sms.server.spring.webmvc.properties.SmsWebmvcProperties; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * 短信webmvc自动配置 + * + * @author guer + */ +@Slf4j +@Configuration +@AutoConfigureAfter(SmsAutoConfiguration.class) +@EnableConfigurationProperties(SmsWebmvcProperties.class) +@ConditionalOnProperty(prefix = SmsWebmvcProperties.PREFIX, name = "enable", havingValue = "true") +public class SmsWebmvcConfiguration { + + @Bean + @ConditionalOnMissingBean(SmsController.class) + public SmsController smsController(VerificationCodeService verificationCodeService, NoticeService noticeService) { + return new SmsController(verificationCodeService, noticeService); + } +} diff --git a/guerlab-sms-server-webmvc-starter/src/main/java/net/guerlab/sms/server/spring/webmvc/autoconfigure/SmsWebmvcPathConfiguration.java b/guerlab-sms-server-webmvc-starter/src/main/java/net/guerlab/sms/server/spring/webmvc/autoconfigure/SmsWebmvcPathConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..217cbd0bffe1dbe4859c7d5ad2ed3e86a63c082b --- /dev/null +++ b/guerlab-sms-server-webmvc-starter/src/main/java/net/guerlab/sms/server/spring/webmvc/autoconfigure/SmsWebmvcPathConfiguration.java @@ -0,0 +1,114 @@ +/* + * Copyright 2018-2022 the original author or authors. + * + * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.gnu.org/licenses/lgpl-3.0.html + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.guerlab.sms.server.spring.webmvc.autoconfigure; + +import lombok.extern.slf4j.Slf4j; +import net.guerlab.sms.core.domain.NoticeInfo; +import net.guerlab.sms.core.domain.VerifyInfo; +import net.guerlab.sms.core.utils.StringUtils; +import net.guerlab.sms.server.properties.SmsWebConfig; +import net.guerlab.sms.server.spring.webmvc.controller.SmsController; +import net.guerlab.sms.server.spring.webmvc.properties.SmsWebmvcProperties; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.servlet.mvc.method.RequestMappingInfo; +import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; + +import java.lang.reflect.Method; + +/** + * 短信控制器路径自动配置 + * + * @author guer + */ +@Slf4j +@Configuration +@AutoConfigureAfter(SmsWebmvcConfiguration.class) +@ConditionalOnProperty(prefix = SmsWebmvcProperties.PREFIX, name = "enable", havingValue = "true") +public class SmsWebmvcPathConfiguration { + + private static String getBasePath(SmsWebConfig properties) { + String bathPath = StringUtils.trimToNull(properties.getBasePath()); + + return bathPath == null ? SmsWebConfig.DEFAULT_BASE_PATH : bathPath; + } + + /** + * 构造短信Controller + * + * @param controller + * 短信Controller + * @param mapping + * RequestMappingHandlerMapping + * @param properties + * 短信Web配置 + * @throws NoSuchMethodException + * if a matching method is not found + * or if the name is "<init>"or "<clinit>". + * @throws SecurityException + * If a security manager, s, is present and + * the caller's class loader is not the same as or an + * ancestor of the class loader for the current class and + * invocation of {@link SecurityManager#checkPackageAccess + * s.checkPackageAccess()} denies access to the package + * of this class. + */ + @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") + @Autowired + @ConditionalOnBean(RequestMappingHandlerMapping.class) + public void smsController(SmsWebConfig properties, RequestMappingHandlerMapping mapping, SmsController controller) + throws NoSuchMethodException, SecurityException { + String bathPath = getBasePath(properties); + + if (properties.isEnableSend()) { + Method sendMethod = SmsController.class.getMethod("sendVerificationCode", String.class); + RequestMappingInfo sendInfo = RequestMappingInfo.paths(bathPath + "/verificationCode/{phone}") + .methods(RequestMethod.POST).build(); + mapping.registerMapping(sendInfo, controller, sendMethod); + log.debug("registerMapping: {}", sendInfo); + } else { + log.debug("not register: sendInfo"); + } + if (properties.isEnableGet()) { + Method getMethod = SmsController.class.getMethod("getVerificationCode", String.class, String.class); + RequestMappingInfo getInfo = RequestMappingInfo.paths(bathPath + "/verificationCode/{phone}") + .methods(RequestMethod.GET).produces("application/json").build(); + mapping.registerMapping(getInfo, controller, getMethod); + log.debug("registerMapping: {}", getInfo); + } else { + log.debug("not register: getInfo"); + } + if (properties.isEnableVerify()) { + Method verifyMethod = SmsController.class.getMethod("verifyVerificationCode", VerifyInfo.class); + RequestMappingInfo verifyInfo = RequestMappingInfo.paths(bathPath + "/verificationCode") + .methods(RequestMethod.POST).build(); + mapping.registerMapping(verifyInfo, controller, verifyMethod); + log.debug("registerMapping: {}", verifyInfo); + } else { + log.debug("not register: verifyInfo"); + } + if (properties.isEnableNotice()) { + Method noticeMethod = SmsController.class.getMethod("sendNotice", NoticeInfo.class); + RequestMappingInfo noticeInfo = RequestMappingInfo.paths(bathPath + "/notice").methods(RequestMethod.PUT) + .build(); + mapping.registerMapping(noticeInfo, controller, noticeMethod); + log.debug("registerMapping: {}", noticeInfo); + } else { + log.debug("not register: noticeInfo"); + } + } +} diff --git a/guerlab-sms-server-webmvc-starter/src/main/java/net/guerlab/sms/server/spring/webmvc/autoconfigure/package-info.java b/guerlab-sms-server-webmvc-starter/src/main/java/net/guerlab/sms/server/spring/webmvc/autoconfigure/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..2dc000d4be13a0c3c37d1d3bf71d817082e8c34f --- /dev/null +++ b/guerlab-sms-server-webmvc-starter/src/main/java/net/guerlab/sms/server/spring/webmvc/autoconfigure/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2018-2021 guerlab.net and other contributors. + * + * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.gnu.org/licenses/lgpl-3.0.html + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @author guer + */ +@NonNullApi +package net.guerlab.sms.server.spring.webmvc.autoconfigure; + +import org.springframework.lang.NonNullApi; diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/controller/SmsController.java b/guerlab-sms-server-webmvc-starter/src/main/java/net/guerlab/sms/server/spring/webmvc/controller/SmsController.java similarity index 87% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/controller/SmsController.java rename to guerlab-sms-server-webmvc-starter/src/main/java/net/guerlab/sms/server/spring/webmvc/controller/SmsController.java index 97ce9eeb7d60f77d02f45148aadf3db2b494718c..d748b6f22434cd1d0e9260196e66cfb95a7cc94e 100644 --- a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/controller/SmsController.java +++ b/guerlab-sms-server-webmvc-starter/src/main/java/net/guerlab/sms/server/spring/webmvc/controller/SmsController.java @@ -10,7 +10,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package net.guerlab.sms.server.controller; +package net.guerlab.sms.server.spring.webmvc.controller; import net.guerlab.sms.core.domain.NoticeInfo; import net.guerlab.sms.core.domain.VerifyInfo; @@ -19,7 +19,6 @@ import net.guerlab.sms.core.exception.VerifyFailException; import net.guerlab.sms.core.utils.StringUtils; import net.guerlab.sms.server.service.NoticeService; import net.guerlab.sms.server.service.VerificationCodeService; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; @@ -36,20 +35,15 @@ public class SmsController { /** * 手机验证码服务 */ - private VerificationCodeService verificationCodeService; + private final VerificationCodeService verificationCodeService; /** * 短信通知服务 */ - private NoticeService noticeService; + private final NoticeService noticeService; - @Autowired - public void setVerificationCodeService(VerificationCodeService verificationCodeService) { + public SmsController(VerificationCodeService verificationCodeService, NoticeService noticeService) { this.verificationCodeService = verificationCodeService; - } - - @Autowired - public void setNoticeService(NoticeService noticeService) { this.noticeService = noticeService; } diff --git a/guerlab-sms-server-webmvc-starter/src/main/java/net/guerlab/sms/server/spring/webmvc/controller/package-info.java b/guerlab-sms-server-webmvc-starter/src/main/java/net/guerlab/sms/server/spring/webmvc/controller/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..97d3c50e79f0d89592ebf228621cb8e0403c9e06 --- /dev/null +++ b/guerlab-sms-server-webmvc-starter/src/main/java/net/guerlab/sms/server/spring/webmvc/controller/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2018-2021 guerlab.net and other contributors. + * + * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.gnu.org/licenses/lgpl-3.0.html + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @author guer + */ +@NonNullApi +package net.guerlab.sms.server.spring.webmvc.controller; + +import org.springframework.lang.NonNullApi; diff --git a/guerlab-sms-server-webmvc-starter/src/main/java/net/guerlab/sms/server/spring/webmvc/properties/SmsWebmvcProperties.java b/guerlab-sms-server-webmvc-starter/src/main/java/net/guerlab/sms/server/spring/webmvc/properties/SmsWebmvcProperties.java new file mode 100644 index 0000000000000000000000000000000000000000..dd091356f9fd4059e27b90b015f889401ee7e188 --- /dev/null +++ b/guerlab-sms-server-webmvc-starter/src/main/java/net/guerlab/sms/server/spring/webmvc/properties/SmsWebmvcProperties.java @@ -0,0 +1,27 @@ +/* + * Copyright 2018-2022 the original author or authors. + * + * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.gnu.org/licenses/lgpl-3.0.html + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.guerlab.sms.server.spring.webmvc.properties; + +import net.guerlab.sms.server.properties.SmsWebConfig; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * 短信Web配置 + * + * @author guer + */ +@ConfigurationProperties(prefix = SmsWebmvcProperties.PREFIX) +public class SmsWebmvcProperties extends SmsWebConfig { + + public static final String PREFIX = "sms.web"; +} diff --git a/guerlab-sms-server-webmvc-starter/src/main/java/net/guerlab/sms/server/spring/webmvc/properties/package-info.java b/guerlab-sms-server-webmvc-starter/src/main/java/net/guerlab/sms/server/spring/webmvc/properties/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..d533542bd723c1fee38023f061a7e8ea52d6a01e --- /dev/null +++ b/guerlab-sms-server-webmvc-starter/src/main/java/net/guerlab/sms/server/spring/webmvc/properties/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2018-2021 guerlab.net and other contributors. + * + * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.gnu.org/licenses/lgpl-3.0.html + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @author guer + */ +@NonNullApi +package net.guerlab.sms.server.spring.webmvc.properties; + +import org.springframework.lang.NonNullApi; diff --git a/guerlab-sms-server-webmvc-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/guerlab-sms-server-webmvc-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..8deec465a8fb8c8d3bb39e929d1b636cd4e8473a --- /dev/null +++ b/guerlab-sms-server-webmvc-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -0,0 +1,54 @@ +{ + "groups": [ + { + "name": "sms.web", + "type": "net.guerlab.sms.server.spring.webmvc.properties.SmsWebmvcProperties", + "sourceType": "net.guerlab.sms.server.spring.webmvc.properties.SmsWebmvcProperties", + "description": "短信Web配置." + } + ], + "properties": [ + { + "name": "sms.web.enable", + "type": "java.lang.Boolean", + "sourceType": "net.guerlab.sms.server.spring.webmvc.properties.SmsWebmvcProperties", + "description": "是否启用web端点.", + "defaultValue": "false" + }, + { + "name": "sms.web.base-path", + "type": "java.lang.String", + "sourceType": "net.guerlab.sms.server.spring.webmvc.properties.SmsWebmvcProperties", + "description": "基础路径.", + "defaultValue": "/sms" + }, + { + "name": "sms.web.enable-send", + "type": "java.lang.Boolean", + "sourceType": "net.guerlab.sms.server.spring.webmvc.properties.SmsWebmvcProperties", + "description": "是否启用验证码发送web端点.", + "defaultValue": "true" + }, + { + "name": "sms.web.enable-get", + "type": "java.lang.Boolean", + "sourceType": "net.guerlab.sms.server.spring.webmvc.properties.SmsWebmvcProperties", + "description": "是否启用验证码查询web端点.", + "defaultValue": "true" + }, + { + "name": "sms.web.enable-verify", + "type": "java.lang.Boolean", + "sourceType": "net.guerlab.sms.server.spring.webmvc.properties.SmsWebmvcProperties", + "description": "是否启用验证码验证web端点.", + "defaultValue": "true" + }, + { + "name": "sms.web.enable-notice", + "type": "java.lang.Boolean", + "sourceType": "net.guerlab.sms.server.spring.webmvc.properties.SmsWebmvcProperties", + "description": "是否启用通知发送web端点.", + "defaultValue": "true" + } + ] +} diff --git a/guerlab-sms-server-webmvc-starter/src/main/resources/META-INF/spring.factories b/guerlab-sms-server-webmvc-starter/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000000000000000000000000000000000000..0d6ce549e315c6208a6b4b7685b9d779c2ea537f --- /dev/null +++ b/guerlab-sms-server-webmvc-starter/src/main/resources/META-INF/spring.factories @@ -0,0 +1,3 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ +net.guerlab.sms.server.spring.webmvc.autoconfigure.SmsWebmvcConfiguration,\ +net.guerlab.sms.server.spring.webmvc.autoconfigure.SmsWebmvcPathConfiguration diff --git a/guerlab-sms-server-webmvc-starter/src/test/java/net/guerlab/sms/server/spring/webmvc/AutoConfigurationTest.java b/guerlab-sms-server-webmvc-starter/src/test/java/net/guerlab/sms/server/spring/webmvc/AutoConfigurationTest.java new file mode 100644 index 0000000000000000000000000000000000000000..4ee0bff4e54e26b820db20a16fe10feeef8e294f --- /dev/null +++ b/guerlab-sms-server-webmvc-starter/src/test/java/net/guerlab/sms/server/spring/webmvc/AutoConfigurationTest.java @@ -0,0 +1,61 @@ +/* + * Copyright 2018-2022 the original author or authors. + * + * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.gnu.org/licenses/lgpl-3.0.html + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.guerlab.sms.server.spring.webmvc; + +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; +import net.guerlab.sms.server.spring.autoconfigure.VerificationCodeAutoConfiguration; +import net.guerlab.sms.server.spring.webmvc.autoconfigure.SmsWebmvcConfiguration; +import net.guerlab.sms.server.spring.webmvc.autoconfigure.SmsWebmvcPathConfiguration; +import net.guerlab.sms.server.spring.webmvc.controller.SmsController; +import net.guerlab.sms.server.spring.webmvc.properties.SmsWebmvcProperties; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.springframework.boot.test.util.TestPropertyValues; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; + +import java.util.Optional; + +/** + * 自动配置测试 + * + * @author guer + */ +public class AutoConfigurationTest { + + private AnnotationConfigApplicationContext context; + + @Before + public void setUp() { + context = new AnnotationConfigApplicationContext(); + context.register(SmsAutoConfiguration.class); + context.register(VerificationCodeAutoConfiguration.class); + } + + @After + public void tearDown() { + Optional.of(context).ifPresent(AnnotationConfigApplicationContext::close); + } + + @Test + public void controller() { + TestPropertyValues.of(SmsWebmvcProperties.PREFIX + ".enable=true").applyTo(context); + context.register(RequestMappingHandlerMapping.class); + context.register(SmsWebmvcConfiguration.class); + context.register(SmsWebmvcPathConfiguration.class); + context.refresh(); + Assert.assertNotNull(context.getBean(SmsController.class)); + } +} diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/properties/package-info.java b/guerlab-sms-server-webmvc-starter/src/test/java/net/guerlab/sms/server/spring/webmvc/package-info.java similarity index 91% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/properties/package-info.java rename to guerlab-sms-server-webmvc-starter/src/test/java/net/guerlab/sms/server/spring/webmvc/package-info.java index efed0b196f757438fcd583d3c6b315421e590b8d..3cd7e50934fb5d6e7063bf6497a21c7371baec4e 100644 --- a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/properties/package-info.java +++ b/guerlab-sms-server-webmvc-starter/src/test/java/net/guerlab/sms/server/spring/webmvc/package-info.java @@ -15,6 +15,6 @@ * @author guer */ @NonNullApi -package net.guerlab.sms.server.properties; +package net.guerlab.sms.server.spring.webmvc; import org.springframework.lang.NonNullApi; diff --git a/guerlab-sms-server/pom.xml b/guerlab-sms-server/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..4eb866478c314c6cb34aaba1731fc93765304b91 --- /dev/null +++ b/guerlab-sms-server/pom.xml @@ -0,0 +1,44 @@ + + 4.0.0 + guerlab-sms-server + + + net.guerlab.sms + guerlab-sms + ${revision} + + + + ${basedir}/.. + + + + + net.guerlab.sms + guerlab-sms-core + + + + org.springframework.boot + spring-boot-starter-web + + + net.guerlab.loadbalancer + guerlab-loadbalancer + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + org.springframework.boot + spring-boot-starter-test + test + + + diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/entity/SmsSendFailEvent.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/entity/SmsSendFailEvent.java similarity index 100% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/entity/SmsSendFailEvent.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/entity/SmsSendFailEvent.java diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/entity/SmsSendFinallyEvent.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/entity/SmsSendFinallyEvent.java similarity index 100% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/entity/SmsSendFinallyEvent.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/entity/SmsSendFinallyEvent.java diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/entity/SmsSendSuccessEvent.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/entity/SmsSendSuccessEvent.java similarity index 100% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/entity/SmsSendSuccessEvent.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/entity/SmsSendSuccessEvent.java diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/entity/VerificationCode.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/entity/VerificationCode.java similarity index 100% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/entity/VerificationCode.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/entity/VerificationCode.java diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/entity/package-info.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/entity/package-info.java similarity index 100% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/entity/package-info.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/entity/package-info.java diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/handler/AbstractSendHandler.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/handler/AbstractSendHandler.java similarity index 100% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/handler/AbstractSendHandler.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/handler/AbstractSendHandler.java diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/handler/SmsSendFailEventListener.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/handler/SmsSendFailEventListener.java similarity index 100% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/handler/SmsSendFailEventListener.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/handler/SmsSendFailEventListener.java diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/handler/SmsSendFinallyEventListener.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/handler/SmsSendFinallyEventListener.java similarity index 100% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/handler/SmsSendFinallyEventListener.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/handler/SmsSendFinallyEventListener.java diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/handler/SmsSendSuccessEventListener.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/handler/SmsSendSuccessEventListener.java similarity index 100% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/handler/SmsSendSuccessEventListener.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/handler/SmsSendSuccessEventListener.java diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/handler/package-info.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/handler/package-info.java similarity index 100% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/handler/package-info.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/handler/package-info.java diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/loadbalancer/RandomSmsLoadBalancer.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/loadbalancer/RandomSmsLoadBalancer.java similarity index 100% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/loadbalancer/RandomSmsLoadBalancer.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/loadbalancer/RandomSmsLoadBalancer.java diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/loadbalancer/RoundRobinSmsLoadBalancer.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/loadbalancer/RoundRobinSmsLoadBalancer.java similarity index 100% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/loadbalancer/RoundRobinSmsLoadBalancer.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/loadbalancer/RoundRobinSmsLoadBalancer.java diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/loadbalancer/SmsSenderLoadBalancer.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/loadbalancer/SmsSenderLoadBalancer.java similarity index 100% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/loadbalancer/SmsSenderLoadBalancer.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/loadbalancer/SmsSenderLoadBalancer.java diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/loadbalancer/WeightRandomSmsLoadBalancer.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/loadbalancer/WeightRandomSmsLoadBalancer.java similarity index 100% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/loadbalancer/WeightRandomSmsLoadBalancer.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/loadbalancer/WeightRandomSmsLoadBalancer.java diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/loadbalancer/WeightRoundRobinSmsLoadBalancer.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/loadbalancer/WeightRoundRobinSmsLoadBalancer.java similarity index 100% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/loadbalancer/WeightRoundRobinSmsLoadBalancer.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/loadbalancer/WeightRoundRobinSmsLoadBalancer.java diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/loadbalancer/package-info.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/loadbalancer/package-info.java similarity index 100% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/loadbalancer/package-info.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/loadbalancer/package-info.java diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/properties/AbstractHandlerProperties.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/properties/AbstractHandlerProperties.java similarity index 100% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/properties/AbstractHandlerProperties.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/properties/AbstractHandlerProperties.java diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/properties/RejectPolicy.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/properties/RejectPolicy.java similarity index 100% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/properties/RejectPolicy.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/properties/RejectPolicy.java diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/properties/SmsAsyncProperties.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/properties/SmsAsyncConfig.java similarity index 91% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/properties/SmsAsyncProperties.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/properties/SmsAsyncConfig.java index 22091aebea657b10491107e2a47bc867d957b672..441da62a3d20256615ffd7e60d33014f123857d7 100644 --- a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/properties/SmsAsyncProperties.java +++ b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/properties/SmsAsyncConfig.java @@ -13,7 +13,6 @@ package net.guerlab.sms.server.properties; import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; import java.util.concurrent.TimeUnit; @@ -23,8 +22,7 @@ import java.util.concurrent.TimeUnit; * @author guer */ @Data -@ConfigurationProperties(prefix = "sms.async") -public class SmsAsyncProperties { +public class SmsAsyncConfig { /** * 是否启用异步支持 diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/properties/SmsProperties.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/properties/SmsConfig.java similarity index 84% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/properties/SmsProperties.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/properties/SmsConfig.java index 0715bef7e4f78b393ae0bb44b63959dcaf51f6b7..c23b855b9f55b70062ddd47434f9aac9dc98f1e4 100644 --- a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/properties/SmsProperties.java +++ b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/properties/SmsConfig.java @@ -13,17 +13,14 @@ package net.guerlab.sms.server.properties; import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; /** * 短信配置 * * @author guer - * */ @Data -@ConfigurationProperties(prefix = "sms") -public class SmsProperties { +public class SmsConfig { /** * 手机号码正则规则 diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/properties/SmsWebProperties.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/properties/SmsWebConfig.java similarity index 88% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/properties/SmsWebProperties.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/properties/SmsWebConfig.java index bac3e583db9334dc12b4d8bc45983ab311b0ea5d..282cb4e9abb3541e76c5e89edf0577564eb4d2bb 100644 --- a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/properties/SmsWebProperties.java +++ b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/properties/SmsWebConfig.java @@ -13,17 +13,14 @@ package net.guerlab.sms.server.properties; import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; /** * 短信Web配置 * * @author guer - * */ @Data -@ConfigurationProperties(prefix = "sms.web") -public class SmsWebProperties { +public class SmsWebConfig { /** * 默认基础路径 diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/properties/VerificationCodeProperties.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/properties/VerificationCodeConfig.java similarity index 90% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/properties/VerificationCodeProperties.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/properties/VerificationCodeConfig.java index 1510eb6cba7405c512b4129289529c86acbdaa78..f7c1ce74611c93864c93ee50c548f0c89b35d360 100644 --- a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/properties/VerificationCodeProperties.java +++ b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/properties/VerificationCodeConfig.java @@ -13,7 +13,6 @@ package net.guerlab.sms.server.properties; import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; /** * 验证码配置 @@ -21,8 +20,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties; * @author guer */ @Data -@ConfigurationProperties(prefix = "sms.verification-code") -public class VerificationCodeProperties { +public class VerificationCodeConfig { /** * 默认验证码业务所使用的类型 diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/properties/VerificationCodeMemoryRepositoryProperties.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/properties/VerificationCodeMemoryRepositoryConfig.java similarity index 78% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/properties/VerificationCodeMemoryRepositoryProperties.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/properties/VerificationCodeMemoryRepositoryConfig.java index a368263903531c874b65d90801694e02c7a66946..cd2ea458ff92c1c59454068987d5c6d3b358e46d 100644 --- a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/properties/VerificationCodeMemoryRepositoryProperties.java +++ b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/properties/VerificationCodeMemoryRepositoryConfig.java @@ -13,7 +13,6 @@ package net.guerlab.sms.server.properties; import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; /** * 验证码内存储存配置 @@ -21,8 +20,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties; * @author guer */ @Data -@ConfigurationProperties(prefix = "sms.verification-code.repository.memory") -public class VerificationCodeMemoryRepositoryProperties { +public class VerificationCodeMemoryRepositoryConfig { /** * 默认gc频率,单位秒 diff --git a/guerlab-sms-redis-repository-starter/src/main/java/net/guerlab/sms/server/properties/package-info.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/properties/package-info.java similarity index 100% rename from guerlab-sms-redis-repository-starter/src/main/java/net/guerlab/sms/server/properties/package-info.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/properties/package-info.java diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/repository/VerificationCodeMemoryRepository.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/repository/VerificationCodeMemoryRepository.java similarity index 89% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/repository/VerificationCodeMemoryRepository.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/repository/VerificationCodeMemoryRepository.java index fe8cca12f6713d87e31882d31e8c7fc45beace60..909fdb1b912dfaa06c1149bfadab8c666bd13035 100644 --- a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/repository/VerificationCodeMemoryRepository.java +++ b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/repository/VerificationCodeMemoryRepository.java @@ -15,7 +15,7 @@ package net.guerlab.sms.server.repository; import lombok.extern.slf4j.Slf4j; import net.guerlab.sms.core.utils.StringUtils; import net.guerlab.sms.server.entity.VerificationCode; -import net.guerlab.sms.server.properties.VerificationCodeMemoryRepositoryProperties; +import net.guerlab.sms.server.properties.VerificationCodeMemoryRepositoryConfig; import org.springframework.lang.Nullable; import java.time.LocalDateTime; @@ -45,7 +45,11 @@ public class VerificationCodeMemoryRepository implements VerificationCodeReposit private final Runnable task = this::gcHandler; - private VerificationCodeMemoryRepositoryProperties properties; + private VerificationCodeMemoryRepositoryConfig config; + + public VerificationCodeMemoryRepository(VerificationCodeMemoryRepositoryConfig config) { + setConfig(config); + } @Override public VerificationCode findOne(String phone, @Nullable String identificationCode) { @@ -79,8 +83,8 @@ public class VerificationCodeMemoryRepository implements VerificationCodeReposit cache.remove(key(phone, identificationCode)); } - public void setProperties(VerificationCodeMemoryRepositoryProperties properties) { - this.properties = properties; + public void setConfig(VerificationCodeMemoryRepositoryConfig config) { + this.config = config; initGcThread(); } @@ -93,9 +97,9 @@ public class VerificationCodeMemoryRepository implements VerificationCodeReposit } private void initGcThread() { - long gcFrequency = properties.getGcFrequency(); + long gcFrequency = config.getGcFrequency(); if (gcFrequency <= 0) { - gcFrequency = VerificationCodeMemoryRepositoryProperties.DEFAULT_GC_FREQUENCY; + gcFrequency = VerificationCodeMemoryRepositoryConfig.DEFAULT_GC_FREQUENCY; } gcScheduledExecutor.remove(task); diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/repository/VerificationCodeRepository.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/repository/VerificationCodeRepository.java similarity index 100% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/repository/VerificationCodeRepository.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/repository/VerificationCodeRepository.java diff --git a/guerlab-sms-redis-repository-starter/src/main/java/net/guerlab/sms/server/repository/package-info.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/repository/package-info.java similarity index 100% rename from guerlab-sms-redis-repository-starter/src/main/java/net/guerlab/sms/server/repository/package-info.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/repository/package-info.java diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/service/AbstractSendAsyncThreadPoolExecutor.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/service/AbstractSendAsyncThreadPoolExecutor.java similarity index 92% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/service/AbstractSendAsyncThreadPoolExecutor.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/service/AbstractSendAsyncThreadPoolExecutor.java index 2fc975ec75f360cbb49a3a47f3cc0776dd301aa5..7714025c63b2c78152dfca8f7148a5e8ee8304df 100644 --- a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/service/AbstractSendAsyncThreadPoolExecutor.java +++ b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/service/AbstractSendAsyncThreadPoolExecutor.java @@ -13,7 +13,7 @@ package net.guerlab.sms.server.service; import net.guerlab.sms.server.properties.RejectPolicy; -import net.guerlab.sms.server.properties.SmsAsyncProperties; +import net.guerlab.sms.server.properties.SmsAsyncConfig; import org.springframework.lang.Nullable; import java.util.concurrent.RejectedExecutionHandler; @@ -28,10 +28,10 @@ import java.util.concurrent.atomic.AtomicInteger; */ public abstract class AbstractSendAsyncThreadPoolExecutor implements SendAsyncThreadPoolExecutor { - protected final SmsAsyncProperties properties; + protected final SmsAsyncConfig config; - public AbstractSendAsyncThreadPoolExecutor(SmsAsyncProperties properties) { - this.properties = properties; + public AbstractSendAsyncThreadPoolExecutor(SmsAsyncConfig config) { + this.config = config; } /** diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/service/CodeGenerate.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/service/CodeGenerate.java similarity index 100% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/service/CodeGenerate.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/service/CodeGenerate.java diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/service/DefaultCodeGenerate.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/service/DefaultCodeGenerate.java similarity index 70% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/service/DefaultCodeGenerate.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/service/DefaultCodeGenerate.java index 221335ad19deb1a1724af781bb9f08e539bd019b..c4b924f68390a5faac0582b33a16c1fbfb1038dd 100644 --- a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/service/DefaultCodeGenerate.java +++ b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/service/DefaultCodeGenerate.java @@ -12,9 +12,7 @@ */ package net.guerlab.sms.server.service; -import net.guerlab.sms.server.properties.VerificationCodeProperties; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; +import net.guerlab.sms.server.properties.VerificationCodeConfig; import java.text.NumberFormat; import java.util.concurrent.ThreadLocalRandom; @@ -24,19 +22,17 @@ import java.util.concurrent.ThreadLocalRandom; * * @author guer */ -@Component public class DefaultCodeGenerate implements CodeGenerate { - private VerificationCodeProperties properties; + private final VerificationCodeConfig config; - @Autowired - public void setProperties(VerificationCodeProperties properties) { - this.properties = properties; + public DefaultCodeGenerate(VerificationCodeConfig config) { + this.config = config; } @Override public String generate() { - int codeLength = properties.getCodeLength(); + int codeLength = config.getCodeLength(); NumberFormat format = NumberFormat.getInstance(); format.setGroupingUsed(false); diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/service/DefaultNoticeService.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/service/DefaultNoticeService.java similarity index 73% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/service/DefaultNoticeService.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/service/DefaultNoticeService.java index 52a6a8ff3d64a2c97166b3462dcc56ddf5c6a1cc..8dadcf24b4236841c01c771fd25a7dcf108cee4b 100644 --- a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/service/DefaultNoticeService.java +++ b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/service/DefaultNoticeService.java @@ -19,10 +19,9 @@ import net.guerlab.sms.core.exception.NotFindSendHandlerException; import net.guerlab.sms.core.exception.SmsException; import net.guerlab.sms.core.handler.SendHandler; import net.guerlab.sms.core.utils.StringUtils; -import net.guerlab.sms.server.properties.SmsAsyncProperties; -import net.guerlab.sms.server.properties.SmsProperties; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; +import net.guerlab.sms.server.properties.SmsAsyncConfig; +import net.guerlab.sms.server.properties.SmsConfig; +import org.springframework.lang.Nullable; import java.util.Collection; import java.util.List; @@ -35,21 +34,29 @@ import java.util.stream.Collectors; */ @SuppressWarnings("AlibabaServiceOrDaoClassShouldEndWithImpl") @Slf4j -@Service public class DefaultNoticeService implements NoticeService { - private SmsProperties properties; + private final SmsConfig config; - private ILoadBalancer smsSenderLoadbalancer; + private final SmsAsyncConfig asyncConfig; - private SmsAsyncProperties asyncProperties; + private final ILoadBalancer smsSenderLoadbalancer; - private SendAsyncThreadPoolExecutor executor; + private final SendAsyncThreadPoolExecutor executor; + + public DefaultNoticeService(SmsConfig config, SmsAsyncConfig asyncConfig, + ILoadBalancer smsSenderLoadbalancer, + @Nullable SendAsyncThreadPoolExecutor executor) { + this.config = config; + this.asyncConfig = asyncConfig; + this.smsSenderLoadbalancer = smsSenderLoadbalancer; + this.executor = executor; + } @Override public boolean phoneRegValidation(String phone) { - return StringUtils.isNotBlank(phone) && (StringUtils.isBlank(properties.getReg()) || phone - .matches(properties.getReg())); + return StringUtils.isNotBlank(phone) && (StringUtils.isBlank(config.getReg()) || phone.matches( + config.getReg())); } @Override @@ -65,7 +72,7 @@ public class DefaultNoticeService implements NoticeService { @Override public void asyncSend(NoticeData noticeData, Collection phones) { - if (!asyncProperties.isEnable() || executor == null) { + if (!asyncConfig.isEnable() || executor == null) { send(noticeData, phones); return; } @@ -114,24 +121,4 @@ public class DefaultNoticeService implements NoticeService { RuntimeException exception; } - - @Autowired - public void setProperties(SmsProperties properties) { - this.properties = properties; - } - - @Autowired - public void setAsyncProperties(SmsAsyncProperties asyncProperties) { - this.asyncProperties = asyncProperties; - } - - @Autowired(required = false) - public void setExecutor(SendAsyncThreadPoolExecutor executor) { - this.executor = executor; - } - - @Autowired - public void setSmsSenderLoadbalancer(ILoadBalancer smsSenderLoadbalancer) { - this.smsSenderLoadbalancer = smsSenderLoadbalancer; - } } diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/service/DefaultSendAsyncThreadPoolExecutor.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/service/DefaultSendAsyncThreadPoolExecutor.java similarity index 90% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/service/DefaultSendAsyncThreadPoolExecutor.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/service/DefaultSendAsyncThreadPoolExecutor.java index 3fd3d86a3a1de5959f8c7fce26831af5d90eebf9..9e39e43589fd6b411bdeeea9a14d143426e53270 100644 --- a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/service/DefaultSendAsyncThreadPoolExecutor.java +++ b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/service/DefaultSendAsyncThreadPoolExecutor.java @@ -12,7 +12,7 @@ */ package net.guerlab.sms.server.service; -import net.guerlab.sms.server.properties.SmsAsyncProperties; +import net.guerlab.sms.server.properties.SmsAsyncConfig; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; @@ -26,7 +26,7 @@ public class DefaultSendAsyncThreadPoolExecutor extends AbstractSendAsyncThreadP private final ThreadPoolExecutor executor; - public DefaultSendAsyncThreadPoolExecutor(SmsAsyncProperties properties) { + public DefaultSendAsyncThreadPoolExecutor(SmsAsyncConfig properties) { super(properties); executor = new ThreadPoolExecutor(properties.getCorePoolSize(), properties.getMaximumPoolSize(), properties.getKeepAliveTime(), properties.getUnit(), diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/service/DefaultVerificationCodeService.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/service/DefaultVerificationCodeService.java similarity index 80% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/service/DefaultVerificationCodeService.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/service/DefaultVerificationCodeService.java index f7c7ec39c37ccd745e892f92b317e887a6fc7856..971043cc496567ba59ef7fc2f8abb69f76dc71a4 100644 --- a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/service/DefaultVerificationCodeService.java +++ b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/service/DefaultVerificationCodeService.java @@ -18,10 +18,9 @@ import net.guerlab.sms.core.exception.RetryTimeShortException; import net.guerlab.sms.core.exception.TypeIsNullException; import net.guerlab.sms.core.utils.StringUtils; import net.guerlab.sms.server.entity.VerificationCode; -import net.guerlab.sms.server.properties.VerificationCodeProperties; +import net.guerlab.sms.server.properties.VerificationCodeConfig; import net.guerlab.sms.server.repository.VerificationCodeRepository; import net.guerlab.sms.server.utils.RandomUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.lang.Nullable; import org.springframework.stereotype.Service; @@ -40,38 +39,23 @@ import java.util.Objects; @Service public class DefaultVerificationCodeService implements VerificationCodeService { - private VerificationCodeRepository repository; + private final VerificationCodeRepository repository; - private VerificationCodeProperties properties; + private final VerificationCodeConfig config; - private NoticeService noticeService; + private final NoticeService noticeService; - private CodeGenerate codeGenerate; + private final CodeGenerate codeGenerate; - private VerificationCodeTypeGenerate verificationCodeTypeGenerate; + private final VerificationCodeTypeGenerate verificationCodeTypeGenerate; - @Autowired - public void setRepository(VerificationCodeRepository repository) { + public DefaultVerificationCodeService(VerificationCodeRepository repository, VerificationCodeConfig config, + NoticeService noticeService, CodeGenerate codeGenerate, + @Nullable VerificationCodeTypeGenerate verificationCodeTypeGenerate) { this.repository = repository; - } - - @Autowired - public void setProperties(VerificationCodeProperties properties) { - this.properties = properties; - } - - @Autowired - public void setNoticeService(NoticeService noticeService) { + this.config = config; this.noticeService = noticeService; - } - - @Autowired - public void setCodeGenerate(CodeGenerate codeGenerate) { this.codeGenerate = codeGenerate; - } - - @Autowired(required = false) - public void setVerificationCodeTypeGenerate(VerificationCodeTypeGenerate verificationCodeTypeGenerate) { this.verificationCodeTypeGenerate = verificationCodeTypeGenerate; } @@ -90,11 +74,11 @@ public class DefaultVerificationCodeService implements VerificationCodeService { @Nullable private String createIdentificationCode() { - if (!properties.isUseIdentificationCode()) { + if (!config.isUseIdentificationCode()) { return null; } - return RandomUtils.nextString(properties.getIdentificationCodeLength()); + return RandomUtils.nextString(config.getIdentificationCodeLength()); } @Override @@ -117,7 +101,7 @@ public class DefaultVerificationCodeService implements VerificationCodeService { type = verificationCodeTypeGenerate.getType(phone, params); } if (type == null) { - type = properties.getType(); + type = config.getType(); } if (type == null) { throw new TypeIsNullException(); @@ -134,7 +118,7 @@ public class DefaultVerificationCodeService implements VerificationCodeService { private VerificationCodeCheckResult verificationCodeCheck(String phone, @Nullable String identificationCode) { VerificationCode verificationCode = repository.findOne(phone, identificationCode); - Long expirationTime = properties.getExpirationTime(); + Long expirationTime = config.getExpirationTime(); boolean newVerificationCode = false; if (verificationCode == null) { @@ -142,7 +126,7 @@ public class DefaultVerificationCodeService implements VerificationCodeService { verificationCode.setPhone(phone); verificationCode.setIdentificationCode(identificationCode); - Long retryIntervalTime = properties.getRetryIntervalTime(); + Long retryIntervalTime = config.getRetryIntervalTime(); if (expirationTime != null && expirationTime > 0) { verificationCode.setExpirationTime(LocalDateTime.now().plusSeconds(expirationTime)); @@ -172,13 +156,13 @@ public class DefaultVerificationCodeService implements VerificationCodeService { } private Map buildSendParams(VerificationCode verificationCode) { - Long expirationTime = properties.getExpirationTime(); + Long expirationTime = config.getExpirationTime(); Map params = new HashMap<>(4); params.put(MSG_KEY_CODE, verificationCode.getCode()); if (verificationCode.getIdentificationCode() != null) { params.put(MSG_KEY_IDENTIFICATION_CODE, verificationCode.getIdentificationCode()); } - if (properties.isTemplateHasExpirationTime() && expirationTime != null && expirationTime > 0) { + if (config.isTemplateHasExpirationTime() && expirationTime != null && expirationTime > 0) { params.put(MSG_KEY_EXPIRATION_TIME_OF_SECONDS, String.valueOf(expirationTime)); params.put(MSG_KEY_EXPIRATION_TIME_OF_MINUTES, String.valueOf(expirationTime / 60)); } @@ -208,11 +192,11 @@ public class DefaultVerificationCodeService implements VerificationCodeService { boolean verifyData = Objects.equals(verificationCode.getCode(), code); - if (verifyData && properties.isDeleteByVerifySucceed()) { + if (verifyData && config.isDeleteByVerifySucceed()) { repository.delete(phone, identificationCode); } - if (!verifyData && properties.isDeleteByVerifyFail()) { + if (!verifyData && config.isDeleteByVerifyFail()) { repository.delete(phone, identificationCode); } diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/service/NoticeService.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/service/NoticeService.java similarity index 100% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/service/NoticeService.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/service/NoticeService.java diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/service/SendAsyncThreadPoolExecutor.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/service/SendAsyncThreadPoolExecutor.java similarity index 100% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/service/SendAsyncThreadPoolExecutor.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/service/SendAsyncThreadPoolExecutor.java diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/service/VerificationCodeService.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/service/VerificationCodeService.java similarity index 100% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/service/VerificationCodeService.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/service/VerificationCodeService.java diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/service/VerificationCodeTypeGenerate.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/service/VerificationCodeTypeGenerate.java similarity index 100% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/service/VerificationCodeTypeGenerate.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/service/VerificationCodeTypeGenerate.java diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/service/package-info.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/service/package-info.java similarity index 100% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/service/package-info.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/service/package-info.java diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/utils/RandomUtils.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/utils/RandomUtils.java similarity index 100% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/utils/RandomUtils.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/utils/RandomUtils.java diff --git a/guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/utils/package-info.java b/guerlab-sms-server/src/main/java/net/guerlab/sms/server/utils/package-info.java similarity index 100% rename from guerlab-sms-server-starter/src/main/java/net/guerlab/sms/server/utils/package-info.java rename to guerlab-sms-server/src/main/java/net/guerlab/sms/server/utils/package-info.java diff --git a/guerlab-sms-upyun-starter/pom.xml b/guerlab-sms-upyun-starter/pom.xml index 7b65671d58b80bfdd11dfb89439af7c5f4aa2e1e..6e6401067dbe261613f8c8cb930d124778ba24ac 100644 --- a/guerlab-sms-upyun-starter/pom.xml +++ b/guerlab-sms-upyun-starter/pom.xml @@ -20,6 +20,11 @@ guerlab-sms-upyun + + net.guerlab.sms + guerlab-sms-server-starter + + org.springframework.boot spring-boot-configuration-processor diff --git a/guerlab-sms-upyun-starter/src/main/java/net/guerlab/sms/upyun/UpyunAutoConfigure.java b/guerlab-sms-upyun-starter/src/main/java/net/guerlab/sms/upyun/UpyunAutoConfigure.java index 8bd22d9f5d4e3386564444a7f4e75ca66a523126..e95cdb1f0c693204aedd05ac3ba76b0143dc0937 100644 --- a/guerlab-sms-upyun-starter/src/main/java/net/guerlab/sms/upyun/UpyunAutoConfigure.java +++ b/guerlab-sms-upyun-starter/src/main/java/net/guerlab/sms/upyun/UpyunAutoConfigure.java @@ -13,8 +13,8 @@ package net.guerlab.sms.upyun; import com.fasterxml.jackson.databind.ObjectMapper; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.loadbalancer.SmsSenderLoadBalancer; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -30,7 +30,7 @@ import org.springframework.web.client.RestTemplate; */ @Configuration @EnableConfigurationProperties(UpyunProperties.class) -@AutoConfigureAfter(SmsConfiguration.class) +@AutoConfigureAfter(SmsAutoConfiguration.class) public class UpyunAutoConfigure { /** diff --git a/guerlab-sms-upyun-starter/src/test/java/net/guerlab/sms/upyun/UpyunAutoConfigureTest.java b/guerlab-sms-upyun-starter/src/test/java/net/guerlab/sms/upyun/UpyunAutoConfigureTest.java index 528db8a7686350a1d818dcbf0afa7dd7a46dfcfa..2435e8040dae9c930ea732941d2e5071497c80fd 100644 --- a/guerlab-sms-upyun-starter/src/test/java/net/guerlab/sms/upyun/UpyunAutoConfigureTest.java +++ b/guerlab-sms-upyun-starter/src/test/java/net/guerlab/sms/upyun/UpyunAutoConfigureTest.java @@ -13,8 +13,8 @@ package net.guerlab.sms.upyun; import com.fasterxml.jackson.databind.ObjectMapper; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.loadbalancer.RandomSmsLoadBalancer; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -34,7 +34,7 @@ public class UpyunAutoConfigureTest { context = new AnnotationConfigApplicationContext(); context.registerBean("objectMapper", ObjectMapper.class); context.registerBean("smsSenderLoadbalancer", RandomSmsLoadBalancer.class); - context.register(SmsConfiguration.class); + context.register(SmsAutoConfiguration.class); TestPropertyValues.of("sms.upyun.token=token").applyTo(context); TestPropertyValues.of("sms.upyun.templates.test=templateId").applyTo(context); TestPropertyValues.of("sms.upyun.params-orders.test=code").applyTo(context); diff --git a/guerlab-sms-upyun/pom.xml b/guerlab-sms-upyun/pom.xml index 6646fbf3729dc6da82b4e4b2c9b881a19a4bc800..c0390cb9314277365465ce186816739985e744cd 100644 --- a/guerlab-sms-upyun/pom.xml +++ b/guerlab-sms-upyun/pom.xml @@ -17,7 +17,7 @@ net.guerlab.sms - guerlab-sms-server-starter + guerlab-sms-server org.springframework.boot diff --git a/guerlab-sms-yunpian-starter/pom.xml b/guerlab-sms-yunpian-starter/pom.xml index 724f6f0cb81972e4351f8098c74cc796eaf0c45e..9eb7898f2be655b354c83a9f0f3cbbf6bc0c3fb1 100644 --- a/guerlab-sms-yunpian-starter/pom.xml +++ b/guerlab-sms-yunpian-starter/pom.xml @@ -20,6 +20,11 @@ guerlab-sms-yunpian + + net.guerlab.sms + guerlab-sms-server-starter + + org.springframework.boot spring-boot-configuration-processor diff --git a/guerlab-sms-yunpian-starter/src/main/java/net/guerlab/sms/yunpian/YunPianAutoConfigure.java b/guerlab-sms-yunpian-starter/src/main/java/net/guerlab/sms/yunpian/YunPianAutoConfigure.java index 8bd6b7baccbfafa47bc4f0c5da7aa58ec66639d5..f7de6da2f051290bcfcf875aad4fcf4d3f0710f6 100644 --- a/guerlab-sms-yunpian-starter/src/main/java/net/guerlab/sms/yunpian/YunPianAutoConfigure.java +++ b/guerlab-sms-yunpian-starter/src/main/java/net/guerlab/sms/yunpian/YunPianAutoConfigure.java @@ -12,8 +12,8 @@ */ package net.guerlab.sms.yunpian; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.loadbalancer.SmsSenderLoadBalancer; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -28,7 +28,7 @@ import org.springframework.core.type.AnnotatedTypeMetadata; */ @Configuration @EnableConfigurationProperties(YunPianProperties.class) -@AutoConfigureAfter(SmsConfiguration.class) +@AutoConfigureAfter(SmsAutoConfiguration.class) public class YunPianAutoConfigure { /** diff --git a/guerlab-sms-yunpian-starter/src/test/java/net/guerlab/sms/yunpian/YunPianAutoConfigureTest.java b/guerlab-sms-yunpian-starter/src/test/java/net/guerlab/sms/yunpian/YunPianAutoConfigureTest.java index c4c94dab77f6930b6eecc272f901e3ff0083d965..41e8c3357e63c3dfb06f91e5c754b6c671d1a68a 100644 --- a/guerlab-sms-yunpian-starter/src/test/java/net/guerlab/sms/yunpian/YunPianAutoConfigureTest.java +++ b/guerlab-sms-yunpian-starter/src/test/java/net/guerlab/sms/yunpian/YunPianAutoConfigureTest.java @@ -13,8 +13,8 @@ package net.guerlab.sms.yunpian; import com.fasterxml.jackson.databind.ObjectMapper; -import net.guerlab.sms.server.autoconfigure.SmsConfiguration; import net.guerlab.sms.server.loadbalancer.RandomSmsLoadBalancer; +import net.guerlab.sms.server.spring.autoconfigure.SmsAutoConfiguration; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -34,7 +34,7 @@ public class YunPianAutoConfigureTest { context = new AnnotationConfigApplicationContext(); context.registerBean("objectMapper", ObjectMapper.class); context.registerBean("smsSenderLoadbalancer", RandomSmsLoadBalancer.class); - context.register(SmsConfiguration.class); + context.register(SmsAutoConfiguration.class); TestPropertyValues.of("sms.yunpian.apikey=apikey").applyTo(context); TestPropertyValues.of("sms.yunpian.templates.test=templateId").applyTo(context); } diff --git a/guerlab-sms-yunpian/pom.xml b/guerlab-sms-yunpian/pom.xml index 797eaa0cdc7625465d02d369d442e0b321b0131d..a47d7f72fff2ea45c33701c9a59eed0e2dd15017 100644 --- a/guerlab-sms-yunpian/pom.xml +++ b/guerlab-sms-yunpian/pom.xml @@ -17,7 +17,7 @@ net.guerlab.sms - guerlab-sms-server-starter + guerlab-sms-server org.springframework.boot diff --git a/pom.xml b/pom.xml index ccbb4452227ee873d50b4f49623e6896541cbef5..7cca1f6a9508c79541eb1c57dcbca4a6216d1d00 100644 --- a/pom.xml +++ b/pom.xml @@ -46,7 +46,7 @@ - 1.12.0 + 2.0.0 1.8 UTF-8 @@ -56,7 +56,7 @@ 3.0.0-M1 1.6 - 2.1.0.RELEASE + 2.3.0.RELEASE 0.0.3 @@ -187,11 +187,21 @@ guerlab-sms-core ${revision} + + net.guerlab.sms + guerlab-sms-server + ${revision} + net.guerlab.sms guerlab-sms-server-starter ${revision} + + net.guerlab.sms + guerlab-sms-server-webmvc-starter + ${revision} + net.guerlab.sms guerlab-sms-redis-repository-starter @@ -348,6 +358,7 @@ guerlab-sms-core + guerlab-sms-server guerlab-sms-server-starter guerlab-sms-redis-repository-starter @@ -386,5 +397,6 @@ guerlab-sms-yunpian guerlab-sms-yunpian-starter + guerlab-sms-server-webmvc-starter