From 26e43f434efb022f30777265f58d13fb8774c119 Mon Sep 17 00:00:00 2001 From: swr <396341246@qq.com> Date: Thu, 23 May 2024 15:02:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E9=80=81=E7=94=B5=E5=AD=90=E9=82=AE?= =?UTF-8?q?=E4=BB=B6=E9=AA=8C=E8=AF=81=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vordm/controller/LoginController.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/kn-service/biz-vordm/src/main/java/com/kening/vordm/controller/LoginController.java b/kn-service/biz-vordm/src/main/java/com/kening/vordm/controller/LoginController.java index 198caf2..08307db 100644 --- a/kn-service/biz-vordm/src/main/java/com/kening/vordm/controller/LoginController.java +++ b/kn-service/biz-vordm/src/main/java/com/kening/vordm/controller/LoginController.java @@ -1,5 +1,6 @@ package com.kening.vordm.controller; +import com.kening.vordm.entity.Email; import com.kening.vordm.service.DisasterInfoService; import com.kening.vordm.service.EmailService; import com.kening.vordm.vo.UserVo; @@ -8,6 +9,7 @@ import org.springblade.core.tool.api.R; import org.springframework.web.bind.annotation.*; import javax.mail.MessagingException; +import java.util.Random; @RestController @RequiredArgsConstructor @@ -59,4 +61,24 @@ public class LoginController { public R getBladeUserByEmail(String email) { return R.data(disasterInfoService.getBladeUserByEmail(email)); } + + /** + * 发送电子邮件验证码 + * @return + * @throws MessagingException + */ + @GetMapping("/sendEmailVerificationCode") + public R sendEmailVerificationCode(String emailUrl) throws MessagingException { + Email email = new Email(); + Random random = new Random(); + int randomNumber = random.nextInt(999999); + String formattedNumber = String.format("%06d", randomNumber); + email.setSubject("[VoRDM] Please verify your device"); + email.setText("Verification code: "+formattedNumber); + email.setHtmlText(false); + email.setTos(emailUrl.split(",")); + emailService.sendMimeMessage(email); + return R.data(formattedNumber); + } + }