|
@@ -18,6 +18,7 @@ import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 短信演示案例
|
|
|
+ * 请先阅读文档 否则无法使用
|
|
|
*
|
|
|
* @author Lion Li
|
|
|
* @version 4.2.0
|
|
@@ -31,13 +32,17 @@ public class SmsController {
|
|
|
|
|
|
private final SmsProperties smsProperties;
|
|
|
// private final SmsTemplate smsTemplate; // 可以使用spring注入
|
|
|
+// private final AliyunSmsTemplate smsTemplate; // 也可以注入某个厂家的模板工具
|
|
|
|
|
|
@ApiOperation("发送短信Aliyun")
|
|
|
@GetMapping("/sendAliyun")
|
|
|
public R<Object> sendAliyun(@ApiParam("电话号") String phones,
|
|
|
@ApiParam("模板ID") String templateId) {
|
|
|
- if (smsProperties.getEnabled()) {
|
|
|
- R.fail("当前系统没有开启短信功能!");
|
|
|
+ if (!smsProperties.getEnabled()) {
|
|
|
+ return R.fail("当前系统没有开启短信功能!");
|
|
|
+ }
|
|
|
+ if (!SpringUtils.containsBean("aliyunSmsTemplate")) {
|
|
|
+ return R.fail("阿里云依赖未引入!");
|
|
|
}
|
|
|
SmsTemplate smsTemplate = SpringUtils.getBean(SmsTemplate.class);
|
|
|
Map<String, String> map = new HashMap<>(1);
|
|
@@ -50,8 +55,11 @@ public class SmsController {
|
|
|
@GetMapping("/sendTencent")
|
|
|
public R<Object> sendTencent(@ApiParam("电话号") String phones,
|
|
|
@ApiParam("模板ID") String templateId) {
|
|
|
- if (smsProperties.getEnabled()) {
|
|
|
- R.fail("当前系统没有开启短信功能!");
|
|
|
+ if (!smsProperties.getEnabled()) {
|
|
|
+ return R.fail("当前系统没有开启短信功能!");
|
|
|
+ }
|
|
|
+ if (!SpringUtils.containsBean("tencentSmsTemplate")) {
|
|
|
+ return R.fail("腾讯云依赖未引入!");
|
|
|
}
|
|
|
SmsTemplate smsTemplate = SpringUtils.getBean(SmsTemplate.class);
|
|
|
Map<String, String> map = new HashMap<>(1);
|