From 49dd582e5adf60e9806ad6547c57fc58c0da9615 Mon Sep 17 00:00:00 2001 From: syruan <1555146157@163.com> Date: Fri, 8 Dec 2023 17:33:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=85=BE=E8=AE=AF=E4=BA=91=E7=9F=AD=E4=BF=A1SM?= =?UTF-8?q?S=E9=85=8D=E7=BD=AE=E5=8F=8A=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bonus/zlpt/system/config/SmsComponent.java | 16 ++++++++-------- .../system/controller/SmsSendController.java | 3 ++- .../zlpt-system/src/main/resources/bootstrap.yml | 6 ++++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/zlpt-modules/zlpt-system/src/main/java/com/bonus/zlpt/system/config/SmsComponent.java b/zlpt-modules/zlpt-system/src/main/java/com/bonus/zlpt/system/config/SmsComponent.java index 38e03ee..c3016f6 100644 --- a/zlpt-modules/zlpt-system/src/main/java/com/bonus/zlpt/system/config/SmsComponent.java +++ b/zlpt-modules/zlpt-system/src/main/java/com/bonus/zlpt/system/config/SmsComponent.java @@ -26,22 +26,22 @@ import org.springframework.stereotype.Component; @Slf4j public class SmsComponent { - @Value("${sms.sdkAppId}") // 注入参数值 + @Value("${tencent.sms.smsSdkAppId}") // 注入参数值 private String sdkAppId; - @Value("${sms.secretId}") + @Value("${tencent.sms.secretId}") private String secretId; - @Value("${sms.secretKey}") + @Value("${tencent.sms.keysecret}") private String secretKey; - @Value("${sms.signName}") + @Value("${tencent.sms.signName}") private String signName; - @Value("${sms.templateCodeId}") + @Value("${tencent.sms.templateId}") private String templateCodeId; - @Value("${sms.timeout}") + @Value("${tencent.sms.timeout}") private Integer timeout; /** @@ -59,7 +59,7 @@ public class SmsComponent { ClientProfile clientProfile = new ClientProfile(); clientProfile.setHttpProfile(httpProfile); // 实例化要请求产品的client对象,clientProfile是可选的 - return new SmsClient(cred, "ap-beijing", clientProfile); + return new SmsClient(cred, "ap-nanjing", clientProfile); } /** @@ -77,7 +77,7 @@ public class SmsComponent { req.setPhoneNumberSet(phoneNumberSet); req.setSignName(signName); req.setTemplateId(templateId); - //模板内容的参数有几个就设置几个,我这里是两个 + // 根据模板所需参数量选择 String[] templateParamSetOne = {code}; String[] templateParamSetTwo = {code,param2}; req.setTemplateParamSet(templateParamSetOne); diff --git a/zlpt-modules/zlpt-system/src/main/java/com/bonus/zlpt/system/controller/SmsSendController.java b/zlpt-modules/zlpt-system/src/main/java/com/bonus/zlpt/system/controller/SmsSendController.java index 51b3fc9..454c7c0 100644 --- a/zlpt-modules/zlpt-system/src/main/java/com/bonus/zlpt/system/controller/SmsSendController.java +++ b/zlpt-modules/zlpt-system/src/main/java/com/bonus/zlpt/system/controller/SmsSendController.java @@ -4,6 +4,7 @@ import com.bonus.zlpt.common.core.web.controller.BaseController; import com.bonus.zlpt.common.core.web.domain.AjaxResult; import com.bonus.zlpt.system.service.ISmsService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -22,7 +23,7 @@ public class SmsSendController extends BaseController { @Autowired private ISmsService smsService; - @RequestMapping("/send") + @PostMapping("send") public AjaxResult send(@RequestParam("phone") String phone){ try { String msg = smsService.sendCode(phone, 5 * 60 * 1000); diff --git a/zlpt-modules/zlpt-system/src/main/resources/bootstrap.yml b/zlpt-modules/zlpt-system/src/main/resources/bootstrap.yml index c5bf7e4..922af58 100644 --- a/zlpt-modules/zlpt-system/src/main/resources/bootstrap.yml +++ b/zlpt-modules/zlpt-system/src/main/resources/bootstrap.yml @@ -9,11 +9,13 @@ tencent: secretId: AKIDbF1pTyU6iHn6EH9uc9O6kJgrrfI2rV04 keysecret: zGPRJ9z68AGZVMAoHYyDFDAxhR2Xs0Qf # 短信应用ID - smsSdkAppId: 564559 + smsSdkAppId: 1400874270 # 短信签名内容 signName: 作业智慧管控系统小程序 # 正文模板ID - templateId: 2010811 + templateId: 2014173 + # 超时时间 + timeout: 1000 sms: sdkAppId: