Browse Source

用户邮箱验证码

huangxingxing 3 months ago
parent
commit
c4ef9b4d68

+ 10 - 1
src/main/java/com/miniframe/bisiness/system/A00001Service.java

@@ -13,6 +13,7 @@ import com.miniframe.tools.msg.IdentifyingCodeUtil;
 import com.miniframe.utils.MFServiceUtils;
 import org.springframework.util.CollectionUtils;
 
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -91,7 +92,15 @@ public class A00001Service extends A00001BaseModel implements ExecProcessFlow {
             UtilTools.putUserCache(ID, code);
             UtilTools.putCache(XIConstant.CODESENDNUM,verifyNumKey,++codesendNum);
             if(this.getA_a00001().getChannel().equals(MessageChannel.email.getIndex())){
-                MFServiceUtils.getMailService().sendSimpleMail(this.getA_a00001().getMailOrPhone(), "验证码", "您的邮箱验证码:" + code);
+//                MFServiceUtils.getMailService()
+//                        .sendSimpleMail(this.getA_a00001().getMailOrPhone(), "验证码", "您的邮箱验证码:" + code);
+                Map<String, Object> var3 =new HashMap<>();
+                var3.put("username","用户");
+                var3.put("verification_code",code);
+                MFServiceUtils.getMailService()
+                        .sendTemplateMail(this.getA_a00001().getMailOrPhone(), this.getA_a00001().getMailOrPhone(), var3,"mail_script");
+
+
             }else if(this.getA_a00001().getChannel().equals(MessageChannel.phone.getIndex())){
                 IdentifyingCodeUtil.sendSMSAli(this.getA_a00001().getMailOrPhone(),code);
             }

+ 4 - 6
src/main/resources/templates/mail_script.html

@@ -1,9 +1,7 @@
-
-<html lang="zh-CN">
+<!DOCTYPE html>
+<html lang="en" xmlns:th="http://www.thymeleaf.org">
 <head>
     <meta charset="UTF-8">
-    
-    
     <title>您的民用飞机多学科联合设计优化软件注册验证码</title>
     <style>
         body {
@@ -61,10 +59,10 @@
 <body>
     <div class="container">
         <h1>您的民用飞机多学科联合设计优化软件注册验证码</h1>
-        <p>尊敬的{{username}}:</p>
+        <p>尊敬的<span  th:text="${username}"></span>: </p>
         <p>感谢您注册民用飞机多学科联合设计优化软件!您正在进行账号注册的邮箱验证操作。为了保障您的账户安全,请使用以下验证码完成验证。</p>
         <p style="text-align: center;">您的验证码是:</p>
-        <div class="verification-code">{{verification_code}}</div>
+        <div class="verification-code"><span  th:text="${verification_code}"></span ></div>
         <p>请在5分钟内输入此验证码进行验证。请妥善保管此验证码,切勿透露给任何人,包括气动与多学科优化设计研究所的客服人员。</p>
         <p class="note">如果您没有进行注册操作,请忽略此邮件。这可能是他人误输入了您的邮箱地址。</p>
         <div class="footer">

+ 10 - 1
src/test/java/com/miniframe/ApplicationTests.java

@@ -8,8 +8,11 @@ import com.miniframe.utils.MFServiceUtils;
 import freemarker.template.TemplateException;
 import org.junit.jupiter.api.Test;
 import org.springframework.boot.test.context.SpringBootTest;
+import org.thymeleaf.context.Context;
 
 import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
 
 @SpringBootTest
 class ApplicationTests {
@@ -24,7 +27,13 @@ class ApplicationTests {
 
     @Test
     void mailTest(){
-        MFServiceUtils.getMailService().sendSimpleMail("hxx512518@163.com","CAE验证码","abcdef");
+//        MFServiceUtils.getMailService().sendSimpleMail("hxx512518@163.com","CAE验证码","abcdef");
+        Map<String, Object> var3 =new HashMap<>();
+        var3.put("username","1212");
+        var3.put("verification_code","1212:");
+
+        MFServiceUtils.getMailService()
+                        .sendTemplateMail("hxx512518@163.com", "hxx512518@163.com", var3,"mail_script");
     }
 
     @Test