From b82e78ceb8f52b05203f05eb4b14151b1ab408a2 Mon Sep 17 00:00:00 2001
From: “mitao” <“2763622819@qq.com”>
Date: 星期三, 24 十二月 2025 18:52:23 +0800
Subject: [PATCH] feat:下单功能联调及短信对接
---
ruoyi-applet/src/main/java/com/ruoyi/web/controller/tool/MsgUtils.java | 108 +++++++++++++++++++++++++++---------------------------
1 files changed, 54 insertions(+), 54 deletions(-)
diff --git a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/tool/MsgUtils.java b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/tool/MsgUtils.java
index c38d11f..5f7e372 100644
--- a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/tool/MsgUtils.java
+++ b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/tool/MsgUtils.java
@@ -13,58 +13,58 @@
@Slf4j
public class MsgUtils {
-// @Value("${code.config.accessKeyId}")
-// private String accessKeyId;
-// @Value("${code.config.accessKeySecret}")
-// private String accessKeySecret;
-// @Value("${code.config.signName}")
-// private String signName;
-// @Value("${code.config.templateCode}")
-// private String templateCode;
-// @Value("${code.config.signNameTest}")
-// private String signNameTest;
-// @Value("${code.config.templateCodeTest}")
-// private String templateCodeTest;
-//
-// /**
-// * 使用AK&SK初始化账号Client
-// * @param accessKeyId
-// * @param accessKeySecret
-// * @return Client
-// * @throws Exception
-// */
-// public static com.aliyun.dysmsapi20170525.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
-// Config config = new Config()
-// // 您的 AccessKey ID
-// .setAccessKeyId(accessKeyId)
-// // 您的 AccessKey Secret
-// .setAccessKeySecret(accessKeySecret);
-// // 访问的域名
-// config.endpoint = "dysmsapi.aliyuncs.com";
-// return new com.aliyun.dysmsapi20170525.Client(config);
-// }
-//
-// public void sendMsg(String phone,String code) throws Exception {
-// com.aliyun.dysmsapi20170525.Client client = MsgUtils.createClient(accessKeyId,accessKeySecret);
-// SendSmsRequest sendSmsRequest = new SendSmsRequest()
-// .setSignName(signName)
-// .setTemplateCode(templateCode)
-// .setPhoneNumbers(phone)
-// .setTemplateParam("{\"code\":\""+code+"\"}");
-// RuntimeOptions runtime = new RuntimeOptions();
-// try {
-// // 复制代码运行请自行打印 API 的返回值
-// SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime);
-// log.info("短信发送成功:{},{}",sendSmsResponse.getBody().getMessage(),sendSmsResponse.getStatusCode());
-// } catch (TeaException error) {
-// // 如有需要,请打印 error
-// com.aliyun.teautil.Common.assertAsString(error.message);
-// log.info("短信发送失败:{}",error.message);
-// } catch (Exception _error) {
-// TeaException error = new TeaException(_error.getMessage(), _error);
-// // 如有需要,请打印 error
-// com.aliyun.teautil.Common.assertAsString(error.message);
-// log.info("短信发送失败:{}",error.message);
-// }
-// }
+ @Value("${code.config.accessKeyId}")
+ private String accessKeyId;
+ @Value("${code.config.accessKeySecret}")
+ private String accessKeySecret;
+ @Value("${code.config.signName}")
+ private String signName;
+ @Value("${code.config.templateCode}")
+ private String templateCode;
+ @Value("${code.config.signNameTest}")
+ private String signNameTest;
+ @Value("${code.config.templateCodeTest}")
+ private String templateCodeTest;
+
+ /**
+ * 使用AK&SK初始化账号Client
+ * @param accessKeyId
+ * @param accessKeySecret
+ * @return Client
+ * @throws Exception
+ */
+ public static com.aliyun.dysmsapi20170525.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
+ Config config = new Config()
+ // 您的 AccessKey ID
+ .setAccessKeyId(accessKeyId)
+ // 您的 AccessKey Secret
+ .setAccessKeySecret(accessKeySecret);
+ // 访问的域名
+ config.endpoint = "dysmsapi.aliyuncs.com";
+ return new com.aliyun.dysmsapi20170525.Client(config);
+ }
+
+ public void sendMsg(String phone,String code) throws Exception {
+ com.aliyun.dysmsapi20170525.Client client = MsgUtils.createClient(accessKeyId,accessKeySecret);
+ SendSmsRequest sendSmsRequest = new SendSmsRequest()
+ .setSignName(signName)
+ .setTemplateCode(templateCode)
+ .setPhoneNumbers(phone)
+ .setTemplateParam("{\"code\":\""+code+"\"}");
+ RuntimeOptions runtime = new RuntimeOptions();
+ try {
+ // 复制代码运行请自行打印 API 的返回值
+ SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime);
+ log.info("短信发送成功:{},{}",sendSmsResponse.getBody().getMessage(),sendSmsResponse.getStatusCode());
+ } catch (TeaException error) {
+ // 如有需要,请打印 error
+ com.aliyun.teautil.Common.assertAsString(error.message);
+ log.info("短信发送失败:{}",error.message);
+ } catch (Exception _error) {
+ TeaException error = new TeaException(_error.getMessage(), _error);
+ // 如有需要,请打印 error
+ com.aliyun.teautil.Common.assertAsString(error.message);
+ log.info("短信发送失败:{}",error.message);
+ }
+ }
}
--
Gitblit v1.7.1