diff --git a/ruoyi-ui/src/api/system/sms/smsChannel.js b/ruoyi-ui/src/api/system/sms/smsChannel.js new file mode 100644 index 000000000..0b4b8c338 --- /dev/null +++ b/ruoyi-ui/src/api/system/sms/smsChannel.js @@ -0,0 +1,44 @@ +import request from '@/utils/request' + +// 创建短信渠道 +export function createSmsChannel(data) { + return request({ + url: '/system/sms-channel/create', + method: 'post', + data: data + }) +} + +// 更新短信渠道 +export function updateSmsChannel(data) { + return request({ + url: '/system/sms-channel/update', + method: 'put', + data: data + }) +} + +// 删除短信渠道 +export function deleteSmsChannel(id) { + return request({ + url: '/system/sms-channel/delete?id=' + id, + method: 'delete' + }) +} + +// 获得短信渠道 +export function getSmsChannel(id) { + return request({ + url: '/system/sms-channel/get?id=' + id, + method: 'get' + }) +} + +// 获得短信渠道分页 +export function getSmsChannelPage(query) { + return request({ + url: '/system/sms-channel/page', + method: 'get', + params: query + }) +} diff --git a/ruoyi-ui/src/utils/dict.js b/ruoyi-ui/src/utils/dict.js index 3817a86fe..bf6d72587 100644 --- a/ruoyi-ui/src/utils/dict.js +++ b/ruoyi-ui/src/utils/dict.js @@ -17,6 +17,7 @@ export const DICT_TYPE = { SYS_OPERATE_TYPE: 'sys_operate_type', SYS_LOGIN_RESULT: 'sys_login_result', SYS_CONFIG_TYPE: 'sys_config_type', + SYS_SMS_CHANNEL_CODE: 'sys_sms_channel_code', INF_REDIS_TIMEOUT_TYPE: 'inf_redis_timeout_type', INF_JOB_STATUS: 'inf_job_status', diff --git a/ruoyi-ui/src/views/system/sms/smsChannel.vue b/ruoyi-ui/src/views/system/sms/smsChannel.vue new file mode 100644 index 000000000..5b19f6a8d --- /dev/null +++ b/ruoyi-ui/src/views/system/sms/smsChannel.vue @@ -0,0 +1,541 @@ + + + + + diff --git a/src/main/java/cn/iocoder/dashboard/framework/sms/core/client/impl/SmsClientFactoryImpl.java b/src/main/java/cn/iocoder/dashboard/framework/sms/core/client/impl/SmsClientFactoryImpl.java index cd5197193..35961fa8f 100644 --- a/src/main/java/cn/iocoder/dashboard/framework/sms/core/client/impl/SmsClientFactoryImpl.java +++ b/src/main/java/cn/iocoder/dashboard/framework/sms/core/client/impl/SmsClientFactoryImpl.java @@ -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); diff --git a/src/main/java/cn/iocoder/dashboard/framework/sms/core/client/impl/aliyun/AliyunSmsClient.java b/src/main/java/cn/iocoder/dashboard/framework/sms/core/client/impl/aliyun/AliyunSmsClient.java index 954250788..8dae88586 100644 --- a/src/main/java/cn/iocoder/dashboard/framework/sms/core/client/impl/aliyun/AliyunSmsClient.java +++ b/src/main/java/cn/iocoder/dashboard/framework/sms/core/client/impl/aliyun/AliyunSmsClient.java @@ -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 diff --git a/src/main/java/cn/iocoder/dashboard/framework/sms/core/client/impl/yunpian/YunpianSmsClient.java b/src/main/java/cn/iocoder/dashboard/framework/sms/core/client/impl/yunpian/YunpianSmsClient.java index ea0aedf13..59c61e45e 100644 --- a/src/main/java/cn/iocoder/dashboard/framework/sms/core/client/impl/yunpian/YunpianSmsClient.java +++ b/src/main/java/cn/iocoder/dashboard/framework/sms/core/client/impl/yunpian/YunpianSmsClient.java @@ -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 diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/sms/SmsChannelController.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/sms/SmsChannelController.java index 359f17f0b..1000a9b02 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/sms/SmsChannelController.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/sms/SmsChannelController.java @@ -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 diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/sms/vo/channel/SysSmsChannelBaseVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/sms/vo/channel/SysSmsChannelBaseVO.java index 141033082..df760c862 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/sms/vo/channel/SysSmsChannelBaseVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/sms/vo/channel/SysSmsChannelBaseVO.java @@ -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; + }