From 261971a8deb15f22c398cb896558eea06f52535b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E6=AF=85=E9=AA=8F?= Date: Tue, 11 Apr 2023 14:38:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/zyjblogs/sms/common/SmsRequest.java | 42 +++++++++++++++---- .../task/service/impl/SmsTaskServiceImpl.java | 18 ++------ 2 files changed, 39 insertions(+), 21 deletions(-) diff --git a/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/common/SmsRequest.java b/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/common/SmsRequest.java index 9d24e25..854f903 100644 --- a/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/common/SmsRequest.java +++ b/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/common/SmsRequest.java @@ -1,19 +1,14 @@ package cn.zyjblogs.sms.common; -import lombok.AllArgsConstructor; +import cn.zyjblogs.sms.task.po.SmsTaskPO; +import cn.zyjblogs.sms.task.po.SmsTemplatePO; import lombok.Builder; import lombok.Data; -import lombok.NoArgsConstructor; import java.io.Serializable; import java.util.List; -import java.util.Map; -import java.util.Set; @Data -@AllArgsConstructor -@NoArgsConstructor -@Builder public class SmsRequest implements Serializable { /** * 方法 @@ -72,4 +67,37 @@ public class SmsRequest implements Serializable { private String region; + public SmsRequest(){ + + } + + @Builder + public SmsRequest(SmsTaskPO smsTaskPO, SmsTemplatePO smsTemplate,List telNums) { + this.templateParams = smsTaskPO.getTemplateParams(); + this.taskId = smsTaskPO.getId(); + this.appId = smsTemplate.getAppId(); + this.templateCode = smsTemplate.getTemplateCode(); + this.signName = smsTemplate.getSignName(); + this.accessKey = smsTemplate.getAccessKey(); + this.accessSecret = smsTemplate.getAccessSecret(); + this.telNums = telNums; + this.region = smsTemplate.getRegion(); + this.smsContent = smsTaskPO.getContent(); + } + @Builder + public SmsRequest(String action, String taskId, List telNums, String appId, String accessKey, String accessSecret, String signName, String templateCode, String endPoint, String templateParams, String smsContent, String templateContent, String region) { + this.action = action; + this.taskId = taskId; + this.telNums = telNums; + this.appId = appId; + this.accessKey = accessKey; + this.accessSecret = accessSecret; + this.signName = signName; + this.templateCode = templateCode; + this.endPoint = endPoint; + this.templateParams = templateParams; + this.smsContent = smsContent; + this.templateContent = templateContent; + this.region = region; + } } diff --git a/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/task/service/impl/SmsTaskServiceImpl.java b/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/task/service/impl/SmsTaskServiceImpl.java index 7fb45db..873b9fa 100644 --- a/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/task/service/impl/SmsTaskServiceImpl.java +++ b/server/zyjblogs-sms/src/main/java/cn/zyjblogs/sms/task/service/impl/SmsTaskServiceImpl.java @@ -143,20 +143,10 @@ public class SmsTaskServiceImpl extends ServiceImpl imp TaskResultDTO taskResultDTO = null; boolean failFlag = false; try { - SmsRequest request = SmsRequest.builder() - .smsContent(data.getContent()) - .templateParams(data.getTemplateParams()) - .taskId(data.getId()) - .appId(template.getAppId()) - .templateCode(template.getTemplateCode()) - .signName(template.getSignName()) - .appId(template.getAppId()) - .accessKey(template.getAccessKey()) - .accessSecret(template.getAccessSecret()) - .telNums(sendPhones) - .region(template.getRegion()) - .build(); - taskResultDTO = smsGranter.sendSms(template.getProviderType(),request); + taskResultDTO = smsGranter.sendSms(template.getProviderType(),SmsRequest.builder() + .smsTaskPO(data) + .smsTemplate(template).telNums(sendPhones) + .build()); }catch (Exception e){ log.warn("短信发送任务发送失败", e); failFlag = true;