短信渠道的前端代码的完成

This commit is contained in:
YunaiV
2021-04-05 21:17:20 +08:00
parent d8d458a024
commit cb1f9a5808
8 changed files with 599 additions and 4 deletions

View File

@ -42,7 +42,8 @@ public class SmsClientFactoryImpl implements SmsClientFactory {
// 初始化 channelCodeClients 集合
Arrays.stream(SmsChannelEnum.values()).forEach(channel -> {
// 创建一个空的 SmsChannelProperties 对象
SmsChannelProperties properties = new SmsChannelProperties().setCode(channel.getCode());
SmsChannelProperties properties = new SmsChannelProperties().setCode(channel.getCode())
.setApiKey("default").setApiSecret("default");
// 创建 Sms 客户端
AbstractSmsClient smsClient = createSmsClient(properties);
channelCodeClients.put(channel.getCode(), smsClient);

View File

@ -1,5 +1,6 @@
package cn.iocoder.dashboard.framework.sms.core.client.impl.aliyun;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.dashboard.common.core.KeyValue;
import cn.iocoder.dashboard.framework.sms.core.client.SmsCommonResult;
@ -50,6 +51,8 @@ public class AliyunSmsClient extends AbstractSmsClient {
public AliyunSmsClient(SmsChannelProperties properties) {
super(properties, new AliyunSmsCodeMapping());
Assert.notEmpty(properties.getApiKey(), "apiKey 不能为空");
Assert.notEmpty(properties.getApiSecret(), "apiSecret 不能为空");
}
@Override

View File

@ -1,6 +1,7 @@
package cn.iocoder.dashboard.framework.sms.core.client.impl.yunpian;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil;
import cn.iocoder.dashboard.common.core.KeyValue;
@ -41,6 +42,7 @@ public class YunpianSmsClient extends AbstractSmsClient {
public YunpianSmsClient(SmsChannelProperties properties) {
super(properties, new YunpianSmsCodeMapping());
Assert.notEmpty(properties.getApiKey(), "apiKey 不能为空");
}
@Override

View File

@ -22,7 +22,7 @@ import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
@Api(tags = "短信渠道")
@RestController
@RequestMapping("/sms/channel")
@RequestMapping("system/sms-channel")
public class SmsChannelController {
@Resource

View File

@ -2,6 +2,7 @@ package cn.iocoder.dashboard.modules.system.controller.sms.vo.channel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.URL;
import javax.validation.constraints.NotNull;
@ -16,8 +17,8 @@ public class SysSmsChannelBaseVO {
@NotNull(message = "短信签名不能为空")
private String signature;
@ApiModelProperty(value = "任务状态", required = true, example = "1")
@NotNull(message = "任务状态不能为空")
@ApiModelProperty(value = "启用状态", required = true, example = "1")
@NotNull(message = "启用状态不能为空")
private Integer status;
@ApiModelProperty(value = "备注", example = "好吃!")
@ -31,6 +32,8 @@ public class SysSmsChannelBaseVO {
private String apiSecret;
@ApiModelProperty(value = "短信发送回调 URL", example = "http://www.iocoder.cn")
@URL(message = "回调 URL 格式不正确")
private String callbackUrl;
}