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;