mirror of
https://gitee.com/dromara/sms4j.git
synced 2025-12-07 09:29:08 +08:00
修复云片短信未能如期创建实现
This commit is contained in:
parent
c21a20467e
commit
d9b5b12a69
@ -13,6 +13,7 @@ import org.dromara.sms4j.huawei.config.HuaweiSmsConfig;
|
|||||||
import org.dromara.sms4j.jdcloud.config.JdCloudSmsConfig;
|
import org.dromara.sms4j.jdcloud.config.JdCloudSmsConfig;
|
||||||
import org.dromara.sms4j.tencent.config.TencentSmsConfig;
|
import org.dromara.sms4j.tencent.config.TencentSmsConfig;
|
||||||
import org.dromara.sms4j.unisms.config.UniSmsConfig;
|
import org.dromara.sms4j.unisms.config.UniSmsConfig;
|
||||||
|
import org.dromara.sms4j.yunpian.config.YunPianSmsConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SmsFactory
|
* SmsFactory
|
||||||
@ -52,6 +53,8 @@ public abstract class SmsFactory {
|
|||||||
return EmaySmsConfig.createEmaySms(SupplierFactory.getEmayConfig());
|
return EmaySmsConfig.createEmaySms(SupplierFactory.getEmayConfig());
|
||||||
case CTYUN:
|
case CTYUN:
|
||||||
return CtyunSmsConfig.createCtyunSms(SupplierFactory.getCtyunConfig());
|
return CtyunSmsConfig.createCtyunSms(SupplierFactory.getCtyunConfig());
|
||||||
|
case YUNPIAN:
|
||||||
|
return YunPianSmsConfig.createTencentSms(SupplierFactory.getYunpianConfig());
|
||||||
}
|
}
|
||||||
throw new SmsBlendException("An attempt to construct a SmsBlend object failed. Please check that the enumeration is valid");
|
throw new SmsBlendException("An attempt to construct a SmsBlend object failed. Please check that the enumeration is valid");
|
||||||
}
|
}
|
||||||
@ -72,6 +75,7 @@ public abstract class SmsFactory {
|
|||||||
CloopenSmsConfig.refresh(SupplierFactory.getCloopenConfig());
|
CloopenSmsConfig.refresh(SupplierFactory.getCloopenConfig());
|
||||||
EmaySmsConfig.refresh(SupplierFactory.getEmayConfig());
|
EmaySmsConfig.refresh(SupplierFactory.getEmayConfig());
|
||||||
CtyunSmsConfig.refresh(SupplierFactory.getCtyunConfig());
|
CtyunSmsConfig.refresh(SupplierFactory.getCtyunConfig());
|
||||||
|
YunPianSmsConfig.refresh(SupplierFactory.getYunpianConfig());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -107,6 +111,9 @@ public abstract class SmsFactory {
|
|||||||
case CTYUN:
|
case CTYUN:
|
||||||
CtyunSmsConfig.refresh(SupplierFactory.getCtyunConfig());
|
CtyunSmsConfig.refresh(SupplierFactory.getCtyunConfig());
|
||||||
break;
|
break;
|
||||||
|
case YUNPIAN:
|
||||||
|
YunPianSmsConfig.refresh(SupplierFactory.getYunpianConfig());
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new SmsBlendException("An attempt to construct a SmsBlend object failed. Please check that the enumeration is valid");
|
throw new SmsBlendException("An attempt to construct a SmsBlend object failed. Please check that the enumeration is valid");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,22 +3,43 @@ package org.dromara.sms4j.yunpian.config;
|
|||||||
import com.dtflys.forest.Forest;
|
import com.dtflys.forest.Forest;
|
||||||
import com.dtflys.forest.config.ForestConfiguration;
|
import com.dtflys.forest.config.ForestConfiguration;
|
||||||
import org.dromara.sms4j.api.SmsBlend;
|
import org.dromara.sms4j.api.SmsBlend;
|
||||||
|
import org.dromara.sms4j.comm.factory.BeanFactory;
|
||||||
|
import org.dromara.sms4j.tencent.config.TencentSmsConfig;
|
||||||
import org.dromara.sms4j.yunpian.service.YunPianSmsImpl;
|
import org.dromara.sms4j.yunpian.service.YunPianSmsImpl;
|
||||||
|
|
||||||
public class YunPianSmsConfig {
|
public class YunPianSmsConfig {
|
||||||
|
|
||||||
|
private static YunPianSmsImpl yunpianSmsImpl;
|
||||||
|
|
||||||
public YunpianConfig yunpianConfig(){
|
private static YunPianSmsConfig yunPianSmsConfig;
|
||||||
return YunpianConfig.builder().build();
|
|
||||||
|
private YunPianSmsConfig() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
public ForestConfiguration forestConfiguration(YunpianConfig yunpianConfig) {
|
* 建造一个云片短信实现
|
||||||
return Forest.config().setBackendName("httpclient");
|
*/
|
||||||
|
public static YunPianSmsImpl createTencentSms(YunpianConfig yunpianConfig){
|
||||||
|
if (yunPianSmsConfig == null) {
|
||||||
|
yunPianSmsConfig = new YunPianSmsConfig();
|
||||||
|
}
|
||||||
|
if (yunpianSmsImpl == null){
|
||||||
|
yunpianSmsImpl = new YunPianSmsImpl(
|
||||||
|
BeanFactory.getExecutor(),
|
||||||
|
BeanFactory.getDelayedTime(),
|
||||||
|
yunpianConfig
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return yunpianSmsImpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 刷新对象*/
|
||||||
public SmsBlend smsBlend() {
|
public static YunPianSmsImpl refresh(YunpianConfig yunpianConfig){
|
||||||
return new YunPianSmsImpl();
|
yunpianSmsImpl = new YunPianSmsImpl(
|
||||||
|
BeanFactory.getExecutor(),
|
||||||
|
BeanFactory.getDelayedTime(),
|
||||||
|
yunpianConfig
|
||||||
|
);
|
||||||
|
return yunpianSmsImpl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,25 +2,21 @@ package org.dromara.sms4j.yunpian.config;
|
|||||||
|
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.ToString;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import org.dromara.sms4j.comm.config.BaseConfig;
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
@SuperBuilder
|
||||||
public class YunpianConfig {
|
@ToString(callSuper = true)
|
||||||
/**
|
@EqualsAndHashCode(callSuper = true)
|
||||||
* 账号唯一标识
|
public class YunpianConfig extends BaseConfig {
|
||||||
*/
|
|
||||||
private String apikey;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 短信发送后将向这个地址推送(运营商返回的)发送报告
|
* 短信发送后将向这个地址推送(运营商返回的)发送报告
|
||||||
*/
|
*/
|
||||||
private String callbackUrl;
|
private String callbackUrl;
|
||||||
|
|
||||||
/**
|
|
||||||
* 模板Id
|
|
||||||
*/
|
|
||||||
private String templateId;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模板变量名称
|
* 模板变量名称
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import org.dromara.sms4j.comm.annotation.Restricted;
|
|||||||
import org.dromara.sms4j.comm.constant.Constant;
|
import org.dromara.sms4j.comm.constant.Constant;
|
||||||
import org.dromara.sms4j.comm.delayedTime.DelayedTime;
|
import org.dromara.sms4j.comm.delayedTime.DelayedTime;
|
||||||
import org.dromara.sms4j.comm.exception.SmsBlendException;
|
import org.dromara.sms4j.comm.exception.SmsBlendException;
|
||||||
|
import org.dromara.sms4j.comm.factory.BeanFactory;
|
||||||
import org.dromara.sms4j.yunpian.config.YunpianConfig;
|
import org.dromara.sms4j.yunpian.config.YunpianConfig;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -20,13 +21,19 @@ import static org.dromara.sms4j.comm.utils.SmsUtil.listToString;
|
|||||||
|
|
||||||
public class YunPianSmsImpl implements SmsBlend {
|
public class YunPianSmsImpl implements SmsBlend {
|
||||||
|
|
||||||
|
public YunPianSmsImpl(Executor pool, DelayedTime delayed, YunpianConfig config) {
|
||||||
|
this.pool = pool;
|
||||||
|
this.delayed = delayed;
|
||||||
|
this.config = config;
|
||||||
|
}
|
||||||
|
|
||||||
private Executor pool;
|
private Executor pool;
|
||||||
|
|
||||||
private DelayedTime delayed;
|
private DelayedTime delayed;
|
||||||
|
|
||||||
private YunpianConfig config;
|
private YunpianConfig config;
|
||||||
|
|
||||||
private ForestConfiguration http;
|
private final ForestConfiguration http = BeanFactory.getForestConfiguration();
|
||||||
|
|
||||||
private static SmsResponse getSmsResponse(JSONObject execute) {
|
private static SmsResponse getSmsResponse(JSONObject execute) {
|
||||||
SmsResponse smsResponse = new SmsResponse();
|
SmsResponse smsResponse = new SmsResponse();
|
||||||
@ -165,7 +172,7 @@ public class YunPianSmsImpl implements SmsBlend {
|
|||||||
message.put(config.getTemplateName(), mes);
|
message.put(config.getTemplateName(), mes);
|
||||||
}
|
}
|
||||||
Map<String, String> body = new HashMap<>();
|
Map<String, String> body = new HashMap<>();
|
||||||
body.put("apikey", config.getApikey());
|
body.put("apikey", config.getAccessKeyId());
|
||||||
body.put("mobile", phone);
|
body.put("mobile", phone);
|
||||||
body.put("tpl_id", tplId);
|
body.put("tpl_id", tplId);
|
||||||
body.put("tpl_value", formattingMap(message));
|
body.put("tpl_value", formattingMap(message));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user