sms4j-solon-plugin: 优化适配,保持与 spring 的体验一致

This commit is contained in:
noear 2025-01-05 08:15:05 +08:00
parent 44287e62d4
commit 2ef232d9ff

View File

@ -22,7 +22,6 @@ import java.util.Map;
/** /**
* smsConfig 参数意义为确保注入时 smsConfig 已经存在 * smsConfig 参数意义为确保注入时 smsConfig 已经存在
*/ */
@Condition(onProperty = "${sms.configType}=yaml")
@Configuration @Configuration
public class SupplierConfigure { public class SupplierConfigure {
@Inject @Inject
@ -35,8 +34,8 @@ public class SupplierConfigure {
} }
@Bean("blends") @Bean("blends")
@Condition(onProperty = "${sms.configType} = yaml")
public Map<String, Map<String, Object>> blends() { public Map<String, Map<String, Object>> blends() {
//确保能产生给下面用//springboot 就算没产生也会给个默认
return context.cfg().getProp("sms.blends").bindTo(new LinkedHashMap<>()); return context.cfg().getProp("sms.blends").bindTo(new LinkedHashMap<>());
} }
@ -67,11 +66,7 @@ public class SupplierConfigure {
public SmsBlendsInitializer smsBlendsInitializer(List<BaseProviderFactory<? extends SmsBlend, ? extends SupplierConfig>> factoryList, public SmsBlendsInitializer smsBlendsInitializer(List<BaseProviderFactory<? extends SmsBlend, ? extends SupplierConfig>> factoryList,
SmsConfig smsConfig, SmsConfig smsConfig,
@Inject("blends") Map<String, Map<String, Object>> blends, @Inject("blends") Map<String, Map<String, Object>> blends,
@Inject(required = false) List<SmsReadConfig> extendsSmsConfigs) { List<SmsReadConfig> extendsSmsConfigs) {
if (extendsSmsConfigs == null) {
extendsSmsConfigs = new ArrayList<>();
}
return new SmsBlendsInitializer(factoryList, smsConfig, blends, extendsSmsConfigs); return new SmsBlendsInitializer(factoryList, smsConfig, blends, extendsSmsConfigs);
} }
} }