From 16df08bbe8a49d028ee2769230f69b8e0916d1f5 Mon Sep 17 00:00:00 2001 From: hanxuanyu <2252193204@qq.com> Date: Mon, 24 Jan 2022 18:02:25 +0800 Subject: [PATCH] =?UTF-8?q?notify=E6=A8=A1=E5=9D=97=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E7=BC=96=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/pom.xml | 4 + .../com/hxuanyu/test/MainApplication.java | 17 +++ .../test/controller/TestController.java | 44 ++++++ .../main/resources/templates/mail/mail.html | 129 ++++++++++++++++++ 4 files changed, 194 insertions(+) create mode 100644 test/src/main/java/com/hxuanyu/test/MainApplication.java create mode 100644 test/src/main/java/com/hxuanyu/test/controller/TestController.java create mode 100644 test/src/main/resources/templates/mail/mail.html diff --git a/test/pom.xml b/test/pom.xml index 6e5f300..5500f06 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -16,6 +16,10 @@ com.hxuanyu notify-spring-boot-starter + + com.hxuanyu + common-spring-boot-starter + org.springframework.boot spring-boot-starter-web diff --git a/test/src/main/java/com/hxuanyu/test/MainApplication.java b/test/src/main/java/com/hxuanyu/test/MainApplication.java new file mode 100644 index 0000000..545499e --- /dev/null +++ b/test/src/main/java/com/hxuanyu/test/MainApplication.java @@ -0,0 +1,17 @@ +package com.hxuanyu.test; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * TODO + * + * @author hanxuanyu + * @version 1.0 + */ +@SpringBootApplication +public class MainApplication { + public static void main(String[] args) { + SpringApplication.run(MainApplication.class, args); + } +} diff --git a/test/src/main/java/com/hxuanyu/test/controller/TestController.java b/test/src/main/java/com/hxuanyu/test/controller/TestController.java new file mode 100644 index 0000000..2aa781b --- /dev/null +++ b/test/src/main/java/com/hxuanyu/test/controller/TestController.java @@ -0,0 +1,44 @@ +package com.hxuanyu.test.controller; + +import com.hxuanyu.common.message.Msg; +import com.hxuanyu.notify.model.Mail; +import com.hxuanyu.notify.service.MailService; +import com.hxuanyu.notify.service.NotifyService; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.Mapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * 测试控制器 + * + * @author hanxuanyu + * @version 1.0 + */ + +@RestController +public class TestController { + + + @Resource + MailService mailService; + + @RequestMapping("/testMail") + public Msg testMail(){ + Mail mail = new Mail(); + mail.setContent("邮件内容"); + mail.setSubject("邮件主题"); + mail.setTo("2252193204@qq.com"); + + try { + mailService.sendMail(mail); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + return Msg.success("发送邮件成功", mail); + } +} diff --git a/test/src/main/resources/templates/mail/mail.html b/test/src/main/resources/templates/mail/mail.html new file mode 100644 index 0000000..0cb7677 --- /dev/null +++ b/test/src/main/resources/templates/mail/mail.html @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + ${title} + + + + + +
+
+

+

+ +
+
+ + + + + \ No newline at end of file