From ee2c731d25f8d0c74a0c1d269c2ae49aa27055ce Mon Sep 17 00:00:00 2001 From: yjb Date: Sat, 25 Jun 2022 10:53:15 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=9F=AD=E4=BF=A1=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=9F=AD=E4=BF=A1=EF=BC=8C=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E7=8A=B6=E6=80=81=E4=B8=8E=E6=B8=A0=E9=81=93?= =?UTF-8?q?=E7=8A=B6=E6=80=81=EF=BC=8C=E5=90=8C=E6=97=B6=E4=B8=BA=E5=BC=80?= =?UTF-8?q?=E5=90=AF=E6=97=B6=E5=8F=91=E9=80=81=E7=9F=AD=E4=BF=A1=EF=BC=8C?= =?UTF-8?q?=E5=90=A6=E5=88=99=E5=8F=AA=E8=AE=B0=E5=BD=95=E7=9F=AD=E4=BF=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/sms/SmsSendServiceImpl.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/sms/SmsSendServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/sms/SmsSendServiceImpl.java index 608985454..bd2f1d409 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/sms/SmsSendServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/sms/SmsSendServiceImpl.java @@ -11,6 +11,7 @@ import cn.iocoder.yudao.framework.sms.core.client.SmsClientFactory; import cn.iocoder.yudao.framework.sms.core.client.SmsCommonResult; import cn.iocoder.yudao.framework.sms.core.client.dto.SmsReceiveRespDTO; import cn.iocoder.yudao.framework.sms.core.client.dto.SmsSendRespDTO; +import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO; import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO; import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; import cn.iocoder.yudao.module.system.mq.message.sms.SmsSendMessage; @@ -40,7 +41,8 @@ public class SmsSendServiceImpl implements SmsSendService { private AdminUserService adminUserService; @Resource private MemberService memberService; - + @Resource + private SmsChannelService smsChannelService; @Resource private SmsTemplateService smsTemplateService; @Resource @@ -80,13 +82,18 @@ public class SmsSendServiceImpl implements SmsSendService { String templateCode, Map templateParams) { // 校验短信模板是否合法 SmsTemplateDO template = this.checkSmsTemplateValid(templateCode); + // 校验短信渠道是否合法 + SmsChannelDO smsChannel = this.checkSmsChannelValid(template.getChannelId()); + // 校验手机号码是否存在 mobile = this.checkMobile(mobile); // 构建有序的模板参数。为什么放在这个位置,是提前保证模板参数的正确性,而不是到了插入发送日志 List> newTemplateParams = this.buildTemplateParams(template, templateParams); // 创建发送日志。如果模板被禁用,则不发送短信,只记录日志 - Boolean isSend = CommonStatusEnum.ENABLE.getStatus().equals(template.getStatus()); + Boolean isSend = CommonStatusEnum.ENABLE.getStatus().equals(template.getStatus()) + && CommonStatusEnum.ENABLE.getStatus().equals(smsChannel.getStatus()); + ; String content = smsTemplateService.formatSmsTemplateContent(template.getContent(), templateParams); Long sendLogId = smsLogService.createSmsLog(mobile, userId, userType, isSend, template, content, templateParams); @@ -98,6 +105,16 @@ public class SmsSendServiceImpl implements SmsSendService { return sendLogId; } + @VisibleForTesting + public SmsChannelDO checkSmsChannelValid(Long channelId) { + // 获得短信模板。考虑到效率,从缓存中获取 + SmsChannelDO channelDO = smsChannelService.getSmsChannel(channelId); + // 短信模板不存在 + if (channelDO == null) { + throw exception(SMS_SEND_TEMPLATE_NOT_EXISTS); + } + return channelDO; + } @VisibleForTesting public SmsTemplateDO checkSmsTemplateValid(String templateCode) { @@ -112,10 +129,10 @@ public class SmsSendServiceImpl implements SmsSendService { /** * 将参数模板,处理成有序的 KeyValue 数组 - * + *

* 原因是,部分短信平台并不是使用 key 作为参数,而是数组下标,例如说腾讯云 https://cloud.tencent.com/document/product/382/39023 * - * @param template 短信模板 + * @param template 短信模板 * @param templateParams 原始参数 * @return 处理后的参数 */ From 45083c89eed0d48db4849502a052c00cd2d491fd Mon Sep 17 00:00:00 2001 From: yjb Date: Sun, 26 Jun 2022 23:20:24 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=EF=BC=8C=E9=81=BF=E5=85=8DVUE=E8=AD=A6?= =?UTF-8?q?=E5=91=8A=20Invalid=20prop:=20type=20check=20failed=20for=20pro?= =?UTF-8?q?p?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-ui-admin/src/views/infra/fileConfig/index.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yudao-ui-admin/src/views/infra/fileConfig/index.vue b/yudao-ui-admin/src/views/infra/fileConfig/index.vue index 08c12793c..2662a0d9d 100755 --- a/yudao-ui-admin/src/views/infra/fileConfig/index.vue +++ b/yudao-ui-admin/src/views/infra/fileConfig/index.vue @@ -77,7 +77,7 @@ - + @@ -91,7 +91,7 @@ - +