notify模块测试内容编写
This commit is contained in:
parent
c100c89f5a
commit
16df08bbe8
@ -16,6 +16,10 @@
|
||||
<groupId>com.hxuanyu</groupId>
|
||||
<artifactId>notify-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.hxuanyu</groupId>
|
||||
<artifactId>common-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
|
17
test/src/main/java/com/hxuanyu/test/MainApplication.java
Normal file
17
test/src/main/java/com/hxuanyu/test/MainApplication.java
Normal file
@ -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);
|
||||
}
|
||||
}
|
@ -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<Mail> 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);
|
||||
}
|
||||
}
|
129
test/src/main/resources/templates/mail/mail.html
Normal file
129
test/src/main/resources/templates/mail/mail.html
Normal file
@ -0,0 +1,129 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
|
||||
<!--${government}-->
|
||||
<!--${title}-->
|
||||
<!--${suggestion}-->
|
||||
<!--${deadline}-->
|
||||
<!--${secret}-->
|
||||
<!--${url}-->
|
||||
<!--${officeName}-->
|
||||
<!--${createTime}-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
|
||||
<title>${title}</title>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
|
||||
<style>
|
||||
.contact-clean {
|
||||
background: #f1f7fc;
|
||||
padding: 80px 0;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.contact-clean {
|
||||
padding: 20px 0;
|
||||
}
|
||||
}
|
||||
|
||||
.contact-clean form {
|
||||
max-width: 480px;
|
||||
width: 90%;
|
||||
margin: 0 auto;
|
||||
background-color: #ffffff;
|
||||
padding: 40px;
|
||||
border-radius: 4px;
|
||||
color: #505e6c;
|
||||
box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.contact-clean form {
|
||||
padding: 30px;
|
||||
}
|
||||
}
|
||||
|
||||
.contact-clean h2 {
|
||||
margin-top: 5px;
|
||||
font-weight: bold;
|
||||
font-size: 28px;
|
||||
margin-bottom: 36px;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.contact-clean .form-group:last-child {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.contact-clean form .form-control {
|
||||
background: #fff;
|
||||
border-radius: 2px;
|
||||
box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.05);
|
||||
outline: none;
|
||||
color: inherit;
|
||||
padding-left: 12px;
|
||||
height: 42px;
|
||||
}
|
||||
|
||||
.contact-clean form .form-control:focus {
|
||||
border: 1px solid #b2b2b2;
|
||||
}
|
||||
|
||||
.contact-clean form textarea.form-control {
|
||||
min-height: 100px;
|
||||
max-height: 260px;
|
||||
padding-top: 10px;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.contact-clean form .btn {
|
||||
padding: 16px 32px;
|
||||
border: none;
|
||||
background: none;
|
||||
box-shadow: none;
|
||||
text-shadow: none;
|
||||
opacity: 0.9;
|
||||
text-transform: uppercase;
|
||||
font-weight: bold;
|
||||
font-size: 13px;
|
||||
letter-spacing: 0.4px;
|
||||
line-height: 1;
|
||||
outline: none !important;
|
||||
}
|
||||
|
||||
.contact-clean form .btn:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.contact-clean form .btn:active {
|
||||
transform: translateY(1px);
|
||||
}
|
||||
|
||||
.contact-clean form .btn-primary {
|
||||
background-color: #055ada !important;
|
||||
margin-top: 15px;
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="contact-clean">
|
||||
<form method="post">
|
||||
<h2 class="text-center" th:text="${mail.getSubject()}"></h2>
|
||||
<p th:utext="${mail.getContent()}"></p>
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<span>
|
||||
<strong>注意</strong>本邮件由系统自动发送,请勿回复本邮件,如果邮件内容您并不知情,请忽略本邮件
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user