|
@@ -5,6 +5,7 @@ import java.util.Map;
|
|
|
|
|
|
import com.chelvc.framework.base.context.JacksonContextHolder;
|
|
import com.chelvc.framework.base.context.JacksonContextHolder;
|
|
import com.chelvc.framework.base.exception.ResourceUnavailableException;
|
|
import com.chelvc.framework.base.exception.ResourceUnavailableException;
|
|
|
|
+import com.chelvc.framework.sms.Captcha;
|
|
import com.chelvc.framework.sms.TemplateSmsHandler;
|
|
import com.chelvc.framework.sms.TemplateSmsHandler;
|
|
import com.chelvc.framework.sms.config.TencentSmsProperties;
|
|
import com.chelvc.framework.sms.config.TencentSmsProperties;
|
|
import com.github.qcloudsms.SmsSingleSender;
|
|
import com.github.qcloudsms.SmsSingleSender;
|
|
@@ -30,6 +31,11 @@ public class TencentSmsHandler implements TemplateSmsHandler {
|
|
private final SmsSingleSender sender;
|
|
private final SmsSingleSender sender;
|
|
private final TencentSmsProperties properties;
|
|
private final TencentSmsProperties properties;
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void send(@NonNull String template, @NonNull Captcha captcha) {
|
|
|
|
+ this.send(captcha.getMobile(), template, captcha.getCode());
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void send(@NonNull String mobile, @NonNull String template, @NonNull String... parameters) {
|
|
public void send(@NonNull String mobile, @NonNull String template, @NonNull String... parameters) {
|
|
boolean debug = log.isDebugEnabled();
|
|
boolean debug = log.isDebugEnabled();
|
|
@@ -41,14 +47,14 @@ public class TencentSmsHandler implements TemplateSmsHandler {
|
|
result = this.sender.sendWithParam(this.properties.getRegion(), mobile, Integer.parseInt(template),
|
|
result = this.sender.sendWithParam(this.properties.getRegion(), mobile, Integer.parseInt(template),
|
|
parameters, this.properties.getSignature(), null, null);
|
|
parameters, this.properties.getSignature(), null, null);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- log.warn("Tencent sms send failed: {}", e.getMessage());
|
|
|
|
|
|
+ log.warn("Tencent sms send failed: {}, {}", mobile, e.getMessage());
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
if (debug) {
|
|
if (debug) {
|
|
- log.debug("Tencent sms response: {}", JacksonContextHolder.serialize(result));
|
|
|
|
|
|
+ log.debug("Tencent sms response: {}, {}", mobile, JacksonContextHolder.serialize(result));
|
|
}
|
|
}
|
|
if (result.result != 0) {
|
|
if (result.result != 0) {
|
|
- log.warn("Tencent sms send failed: [{}] {}", result.result, result.errMsg);
|
|
|
|
|
|
+ log.warn("Tencent sms send failed[{}]: {}, {}", result.result, mobile, result.errMsg);
|
|
if (result.result == 1023) {
|
|
if (result.result == 1023) {
|
|
throw new ResourceUnavailableException(SMS_SEND_FREQUENTLY, result.errMsg);
|
|
throw new ResourceUnavailableException(SMS_SEND_FREQUENTLY, result.errMsg);
|
|
}
|
|
}
|
|
@@ -60,9 +66,4 @@ public class TencentSmsHandler implements TemplateSmsHandler {
|
|
public void send(String mobile, String template, Map<String, ?> parameters) {
|
|
public void send(String mobile, String template, Map<String, ?> parameters) {
|
|
throw new UnsupportedOperationException("Not support method");
|
|
throw new UnsupportedOperationException("Not support method");
|
|
}
|
|
}
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void sendCaptcha(@NonNull String mobile, @NonNull String template, @NonNull String code) {
|
|
|
|
- this.send(mobile, template, code);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|