diff --git a/main/manager-api/pom.xml b/main/manager-api/pom.xml
index d08e32f2..c4234647 100644
--- a/main/manager-api/pom.xml
+++ b/main/manager-api/pom.xml
@@ -28,6 +28,8 @@
1.6.2
33.0.0-jre
4.20.0
+ 4.1.0
+ 3.4.0
@@ -37,6 +39,7 @@
jakarta
${shiro.version}
+
org.apache.shiro
shiro-spring
@@ -201,6 +204,18 @@
com.fasterxml.jackson.datatype
jackson-datatype-jsr310
+
+
+ com.aliyun
+ dysmsapi20170525
+ ${the-latest-version}
+
+
+
+ com.squareup.okio
+ okio
+ ${okio-version}
+
diff --git a/main/manager-api/src/main/java/xiaozhi/common/constant/Constant.java b/main/manager-api/src/main/java/xiaozhi/common/constant/Constant.java
index 78154b5c..171d1a21 100644
--- a/main/manager-api/src/main/java/xiaozhi/common/constant/Constant.java
+++ b/main/manager-api/src/main/java/xiaozhi/common/constant/Constant.java
@@ -146,6 +146,46 @@ public interface Constant {
}
}
+ /**
+ * 系统短信
+ */
+ enum SysMSMParam {
+ /**
+ * 阿里云授权keyID
+ */
+ ALIYUN_SMS_ACCESS_KEY_ID("aliyun.sms.access_key_id"),
+ /**
+ * 阿里云授权密钥
+ */
+ ALIYUN_SMS_ACCESS_KEY_SECRET("aliyun.sms.access_key_secret"),
+ /**
+ *
+ */
+ ALIYUN_SMS_SIGN_NAME("aliyun.sms.sign_name"),
+ /**
+ * 已删除
+ */
+ ALIYUN_SMS_SMS_CODE_TEMPLATE_CODE("aliyun.sms.sms_code_template_code"),
+ /**
+ * 已删除
+ */
+ SYSTEM_SMS_MAX_SEND_COUNT("system.sms.max_send_count"),
+ /**
+ * 是否开启手机注册
+ */
+ SYSTEM_ENABLE_MOBILE_REGISTER("system.enable_mobile_register");
+
+ private String value;
+
+ SysMSMParam(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+ }
+
/**
* 数据状态
*/
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sms/service/SmsService.java b/main/manager-api/src/main/java/xiaozhi/modules/sms/service/SmsService.java
new file mode 100644
index 00000000..c33ad945
--- /dev/null
+++ b/main/manager-api/src/main/java/xiaozhi/modules/sms/service/SmsService.java
@@ -0,0 +1,17 @@
+package xiaozhi.modules.sms.service;
+
+/**
+ * 短信服务的方法定义接口
+ *
+ * @author zjy
+ * @since 2025-05-12
+ */
+public interface SmsService {
+
+ /**
+ * 发送验证码短信
+ * @param phone 手机号码
+ * @param VerificationCode 验证码
+ */
+ void sendVerificationCodeSms(String phone, String VerificationCode) ;
+}
diff --git a/main/manager-api/src/main/java/xiaozhi/modules/sms/service/imp/ALiYunSmsService.java b/main/manager-api/src/main/java/xiaozhi/modules/sms/service/imp/ALiYunSmsService.java
new file mode 100644
index 00000000..0a73bf68
--- /dev/null
+++ b/main/manager-api/src/main/java/xiaozhi/modules/sms/service/imp/ALiYunSmsService.java
@@ -0,0 +1,76 @@
+package xiaozhi.modules.sms.service.imp;
+
+import com.aliyun.dysmsapi20170525.Client;
+import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
+import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
+import com.aliyun.tea.TeaException;
+import com.aliyun.teaopenapi.models.Config;
+import com.aliyun.teautil.Common;
+import com.aliyun.teautil.models.RuntimeOptions;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import xiaozhi.common.constant.Constant;
+import xiaozhi.modules.sms.service.SmsService;
+import xiaozhi.modules.sys.service.SysParamsService;
+
+@Service
+@AllArgsConstructor
+@Slf4j
+public class ALiYunSmsService implements SmsService {
+ private final SysParamsService sysParamsService;
+
+ @Override
+ public void sendVerificationCodeSms(String phone, String VerificationCode) {
+ String SignName = sysParamsService.getValue(Constant.SysMSMParam
+ .ALIYUN_SMS_SIGN_NAME.getValue(),true);
+ String TemplateCode = sysParamsService.getValue(Constant.SysMSMParam
+ .ALIYUN_SMS_SMS_CODE_TEMPLATE_CODE.getValue(),true);
+ try {
+ Client client = createClient();
+ SendSmsRequest sendSmsRequest = new SendSmsRequest()
+ .setSignName(SignName)
+ .setTemplateCode(TemplateCode)
+ .setPhoneNumbers(phone)
+ .setTemplateParam(String.format("{\"code\":\"%s\"}", VerificationCode));
+ RuntimeOptions runtime = new RuntimeOptions();
+ try {
+ // 复制代码运行请自行打印 API 的返回值
+ SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime);
+ System.out.println(sendSmsResponse.getBody().getRequestId());
+ System.out.println(sendSmsResponse.getBody().getRequestId());
+ } catch (TeaException error) {
+ // 错误 message
+ log.error(error.getMessage());
+ // 诊断地址
+ log.error(error.getData().get("Recommend").toString());
+ log.error(Common.assertAsString(error.message));
+ }
+ } catch (Exception e) {
+ // 错误 message
+ log.error(e.getMessage());
+ throw new RuntimeException(e);
+ }
+
+ }
+
+
+ /**
+ * 创建阿里云连接
+ * @return 返回连接对象
+ * @throws Exception
+ */
+ private Client createClient() throws Exception {
+ String ACCESS_KEY_ID = sysParamsService.getValue(Constant.SysMSMParam
+ .ALIYUN_SMS_ACCESS_KEY_ID.getValue(),true);
+ String ACCESS_KEY_SECRET = sysParamsService.getValue(Constant.SysMSMParam
+ .ALIYUN_SMS_ACCESS_KEY_SECRET.getValue(),true);
+ Config config = new Config()
+ .setAccessKeyId(ACCESS_KEY_ID)
+ .setAccessKeySecret(ACCESS_KEY_SECRET);
+ // 配置 Endpoint。中国站请使用dysmsapi.aliyuncs.com
+ config.endpoint = "dysmsapi.aliyuncs.com";
+
+ return new Client(config);
+ }
+}