From b428226d0cf78bbb843fa17bffb1e338230fae6c Mon Sep 17 00:00:00 2001
From: tj <1378534974@qq.com>
Date: 星期一, 21 四月 2025 15:39:59 +0800
Subject: [PATCH] 1.我的邀请记录-头像

---
 src/main/java/com/mzl/flower/service/register/SmsService.java |   26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/src/main/java/com/mzl/flower/service/register/SmsService.java b/src/main/java/com/mzl/flower/service/register/SmsService.java
index 61e3e75..3ac2b11 100644
--- a/src/main/java/com/mzl/flower/service/register/SmsService.java
+++ b/src/main/java/com/mzl/flower/service/register/SmsService.java
@@ -5,8 +5,10 @@
 import com.mzl.flower.config.exception.ValidationException;
 import com.mzl.flower.constant.Constants;
 import com.mzl.flower.dto.request.SmsSendDTO;
+import com.mzl.flower.service.sms.TosSmsService;
 import com.mzl.flower.utils.SmsUtil;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -25,6 +27,10 @@
     private final SmsProperties smsProperties;
 
     private final StringCacheClient stringCacheClient;
+
+    @Autowired
+    private TosSmsService tosSmsService;
+
 
     public SmsService(SmsProperties smsProperties, StringCacheClient stringCacheClient) {
         this.smsProperties = smsProperties;
@@ -50,8 +56,8 @@
         if(existsCode(dto.getTel())){
             throw new ValidationException("短信验证码已发送,请勿频繁发送");
         }
-//        String smsCode = generateSmsCode();
-        String smsCode ="888888";
+        String smsCode = generateSmsCode();
+//        String smsCode ="888888";
         String key;
         if(Constants.USER_TYPE.admin.name().equals(dto.getUserType())){
             key = SMS_CODE_KEY + SEPARATOR + Constants.USER_TYPE.admin.name() + SEPARATOR + dto.getTel();
@@ -67,15 +73,15 @@
 
         Map<String, String> paramMap = new HashMap<>();
         paramMap.put("code", smsCode);
-//        try {
-//            //暂时不实际发送验证码
+        try {
+            //暂时不实际发送验证码
 //            SmsUtil.sendSms(dto.getTel(),smsProperties.getVerificationCode(),paramMap);
-        stringCacheClient.set(SMS_CODE_KEY + SEPARATOR + SEPARATOR + dto.getTel(),smsCode,60);
-        stringCacheClient.set(key,smsCode,600);
-//        } catch (ClientException e) {
-//            throw new RuntimeException("短信发送失败");
-//        }
-        //todo 发送短信
+            tosSmsService.sendSms(dto.getTel(),paramMap);
+            stringCacheClient.set(SMS_CODE_KEY + SEPARATOR + SEPARATOR + dto.getTel(),smsCode,60);
+            stringCacheClient.set(key,smsCode,600);
+        } catch (Exception e) {
+            throw new RuntimeException("短信发送失败");
+        }
     }
 
     private boolean existsCode(String tel) {

--
Gitblit v1.9.3