mirror of
https://gitee.com/dromara/sms4j.git
synced 2025-12-06 08:58:38 +08:00
修复:
1.去除JDK8不存在的依赖 2.去除bean重复扫描的问题
This commit is contained in:
parent
8235c34a7d
commit
adfbd84372
2
pom.xml
2
pom.xml
@ -50,7 +50,7 @@
|
||||
</scm>
|
||||
|
||||
<properties>
|
||||
<revision>3.0.0</revision>
|
||||
<revision>3.0.0-SNAPSHOT</revision>
|
||||
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
|
||||
@ -2,7 +2,6 @@ package org.dromara.sms4j.tencent.service;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.jdcloud.sdk.utils.StringUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.sms4j.api.entity.SmsResponse;
|
||||
import org.dromara.sms4j.comm.constant.Constant;
|
||||
@ -119,7 +118,7 @@ public class TencentSmsImpl extends AbstractSmsBlend<TencentConfig> {
|
||||
SmsResponse smsResponse = new SmsResponse();
|
||||
JSONObject response = resJson.getJSONObject("Response");
|
||||
String error = response.getStr("Error");
|
||||
smsResponse.setSuccess(StringUtils.isBlank(error));
|
||||
smsResponse.setSuccess(StrUtil.isBlank(error));
|
||||
smsResponse.setData(resJson);
|
||||
smsResponse.setConfigId(getConfigId());
|
||||
return smsResponse;
|
||||
|
||||
@ -1,15 +1,14 @@
|
||||
package org.dromara.sms4j.starter.config;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.sms4j.aliyun.config.AlibabaFactory;
|
||||
import org.dromara.sms4j.api.SmsBlend;
|
||||
import org.dromara.sms4j.api.dao.SmsDao;
|
||||
import org.dromara.sms4j.api.dao.SmsDaoDefaultImpl;
|
||||
import org.dromara.sms4j.api.proxy.RestrictedProcess;
|
||||
import org.dromara.sms4j.api.universal.SupplierConfig;
|
||||
import org.dromara.sms4j.cloopen.config.CloopenFactory;
|
||||
import org.dromara.sms4j.comm.constant.Constant;
|
||||
@ -21,6 +20,7 @@ import org.dromara.sms4j.emay.config.EmayFactory;
|
||||
import org.dromara.sms4j.huawei.config.HuaweiFactory;
|
||||
import org.dromara.sms4j.jdcloud.config.JdCloudFactory;
|
||||
import org.dromara.sms4j.netease.config.NeteaseFactory;
|
||||
import org.dromara.sms4j.provider.config.BaseConfig;
|
||||
import org.dromara.sms4j.provider.config.SmsConfig;
|
||||
import org.dromara.sms4j.provider.factory.BaseProviderFactory;
|
||||
import org.dromara.sms4j.provider.factory.ProviderFactoryHolder;
|
||||
@ -29,18 +29,18 @@ import org.dromara.sms4j.tencent.config.TencentFactory;
|
||||
import org.dromara.sms4j.unisms.config.UniFactory;
|
||||
import org.dromara.sms4j.yunpian.config.YunPianFactory;
|
||||
import org.dromara.sms4j.zhutong.config.ZhutongFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@Data
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class SmsBlendsInitializer {
|
||||
|
||||
private final List<BaseProviderFactory<? extends SmsBlend, ? extends SupplierConfig>> factoryList;
|
||||
private List<BaseProviderFactory<? extends SmsBlend, ? extends SupplierConfig>> factoryList;
|
||||
|
||||
private final SmsConfig smsConfig;
|
||||
private final Map<String, Map<String, Object>> blends;
|
||||
@ -93,4 +93,27 @@ public class SmsBlendsInitializer {
|
||||
ProviderFactoryHolder.registerFactory(ZhutongFactory.instance());
|
||||
}
|
||||
|
||||
/**
|
||||
* 将Map中所有key的分隔符转换为新的分隔符
|
||||
* @param map map对象
|
||||
* @param seperator 旧分隔符
|
||||
* @param newSeperator 新分隔符
|
||||
*/
|
||||
public static void replaceKeysSeperator(Map<String, BaseConfig> map, String seperator, String newSeperator) {
|
||||
if(CollUtil.isEmpty(map)) {
|
||||
return;
|
||||
}
|
||||
List<String> keySet = new ArrayList<>(map.keySet());
|
||||
for(String key : keySet) {
|
||||
if(StrUtil.isEmpty(key) || !key.contains(seperator)) {
|
||||
continue;
|
||||
}
|
||||
// String value = String.valueOf(map.get(key));
|
||||
String newKey = key.replaceAll(seperator, newSeperator);
|
||||
newKey = StrUtil.toCamelCase(newKey);
|
||||
map.putIfAbsent(newKey, map.get(key));
|
||||
map.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -4,9 +4,8 @@ import lombok.Data;
|
||||
import org.dromara.sms4j.starter.utils.SmsSpringUtil;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
|
||||
@Data
|
||||
public class SmsMainConfig {
|
||||
|
||||
|
||||
@ -1,18 +1,31 @@
|
||||
package org.dromara.sms4j.starter.config;
|
||||
|
||||
import org.dromara.sms4j.api.SmsBlend;
|
||||
import org.dromara.sms4j.provider.config.BaseConfig;
|
||||
import org.dromara.sms4j.provider.config.SmsConfig;
|
||||
import org.dromara.sms4j.provider.factory.BaseProviderFactory;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class SupplierConfig {
|
||||
|
||||
/** smsConfig参数意义为确保注入时smsConfig已经存在*/
|
||||
/** 注入配置*/
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "sms.blends")
|
||||
protected Map<String, Map<String, Object>> blends(){
|
||||
return new LinkedHashMap<>();
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
protected SmsBlendsInitializer smsBlendsInitializer(List<BaseProviderFactory<? extends SmsBlend, ? extends org.dromara.sms4j.api.universal.SupplierConfig>>factoryList,
|
||||
SmsConfig smsConfig,
|
||||
Map<String, Map<String, Object>> blends){
|
||||
return new SmsBlendsInitializer(factoryList,smsConfig,blends);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
org.dromara.sms4j.starter.config.SmsMainConfig,\
|
||||
org.dromara.sms4j.starter.config.SmsAutowiredConfig,\
|
||||
org.dromara.sms4j.starter.config.SupplierConfig,\
|
||||
org.dromara.sms4j.provider.config.SmsConfig
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
org.dromara.sms4j.starter.config.SmsMainConfig
|
||||
org.dromara.sms4j.starter.config.SmsAutowiredConfig
|
||||
org.dromara.sms4j.starter.config.SupplierConfig
|
||||
org.dromara.sms4j.provider.config.SmsConfig
|
||||
Loading…
x
Reference in New Issue
Block a user