Compare commits
7 Commits
v1.0.2
...
8c47f75673
| Author | SHA1 | Date | |
|---|---|---|---|
| 8c47f75673 | |||
| 16df08bbe8 | |||
| c100c89f5a | |||
| 45ab626751 | |||
| 58d2ce559d | |||
| 6febbb049d | |||
| dab1b9fa55 |
54
README.md
54
README.md
@@ -2,9 +2,63 @@
|
||||
|
||||
本项目基于springboot进行开发,实现了一系列的spring-boot-starter,可以作为开发中的工具包进行使用。
|
||||
|
||||
|
||||
|
||||
### 模块划分
|
||||
|
||||
- common-spring-boot-starter:常用的基础类,比如用作消息流转的`Msg`以及一些工具类
|
||||
- monitor-spring-boot-starter:监控工具包,可以实现定时监控某些数据并在触发条件后实时通知
|
||||
- network-spring-boot-starter:网络工具,实现了一系列http请求发送方法,引入后即可快速发送http请求
|
||||
- notify-spring-boot-starter:通知工具,集成了邮件通知、短信通知等功能
|
||||
|
||||
|
||||
|
||||
## 快速开始
|
||||
|
||||
### 1. 引入maven依赖
|
||||
|
||||
本项目已经上传到中央仓库,使用时在pom文件中添加如下依赖即可:
|
||||
|
||||
- network-spring-boot-starter
|
||||
|
||||
```xml
|
||||
<!--network-spring-boot-starter-->
|
||||
<dependency>
|
||||
<groupId>com.hxuanyu</groupId>
|
||||
<artifactId>network-spring-boot-starter</artifactId>
|
||||
<version>1.0.1</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
- notify-spring-boot-starter
|
||||
|
||||
```xml
|
||||
<!--notify-spring-boot-starter-->
|
||||
<dependency>
|
||||
<groupId>com.hxuanyu</groupId>
|
||||
<artifactId>notify-spring-boot-starter</artifactId>
|
||||
<version>1.0.1</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
- monitor-spring-boot-starter
|
||||
|
||||
```xml
|
||||
<!--monitor-spring-boot-starter-->
|
||||
<dependency>
|
||||
<groupId>com.hxuanyu</groupId>
|
||||
<artifactId>monitor-spring-boot-starter</artifactId>
|
||||
<version>1.0.1</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
- monitor-spring-boot-starter
|
||||
|
||||
```xml
|
||||
<!--monitor-spring-boot-starter-->
|
||||
<dependency>
|
||||
<groupId>com.hxuanyu</groupId>
|
||||
<artifactId>monitor-spring-boot-starter</artifactId>
|
||||
<version>1.0.1</version>
|
||||
</dependency>
|
||||
```
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>hxuanyu-spring-boot-starter-parent</artifactId>
|
||||
<groupId>com.hxuanyu</groupId>
|
||||
<version>1.0.2</version>
|
||||
<version>1.0.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>hxuanyu-spring-boot-starter-parent</artifactId>
|
||||
<groupId>com.hxuanyu</groupId>
|
||||
<version>1.0.2</version>
|
||||
<version>1.0.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>hxuanyu-spring-boot-starter-parent</artifactId>
|
||||
<groupId>com.hxuanyu</groupId>
|
||||
<version>1.0.2</version>
|
||||
<version>1.0.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>hxuanyu-spring-boot-starter-parent</artifactId>
|
||||
<groupId>com.hxuanyu</groupId>
|
||||
<version>1.0.2</version>
|
||||
<version>1.0.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.ImportResource;
|
||||
|
||||
import java.util.concurrent.*;
|
||||
|
||||
|
||||
7
pom.xml
7
pom.xml
@@ -4,7 +4,7 @@
|
||||
|
||||
<groupId>com.hxuanyu</groupId>
|
||||
<artifactId>hxuanyu-spring-boot-starter-parent</artifactId>
|
||||
<version>1.0.2</version>
|
||||
<version>1.0.4-SNAPSHOT</version>
|
||||
<name>hxuanyu-spring-boot-starter-parent</name>
|
||||
<description>MonitorPushingParent</description>
|
||||
<packaging>pom</packaging>
|
||||
@@ -19,7 +19,7 @@
|
||||
<connection>scm:git:https://git.hxuanyu.com/hxuanyu/hxuanyu-spring-boot-starter.git</connection>
|
||||
<developerConnection>scm:git:https://git.hxuanyu.com/hxuanyu/hxuanyu-spring-boot-starter.git</developerConnection>
|
||||
<url>https://git.hxuanyu.com/hxuanyu/hxuanyu-spring-boot-starter</url>
|
||||
<tag>v1.0.2</tag>
|
||||
<tag>v1.0.0</tag>
|
||||
</scm>
|
||||
<developers>
|
||||
<developer>
|
||||
@@ -34,6 +34,7 @@
|
||||
<module>network-spring-boot-starter</module>
|
||||
<module>notify-spring-boot-starter</module>
|
||||
<module>monitor-spring-boot-starter</module>
|
||||
<module>test</module>
|
||||
</modules>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -165,7 +166,7 @@
|
||||
<tagNameFormat>v@{project.version}</tagNameFormat>
|
||||
<autoVersionSubmodules>true</autoVersionSubmodules>
|
||||
<password>${git.password}</password>
|
||||
<username>hxuanyu</username>
|
||||
<username>${git.username}</username>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
51
test/pom.xml
Normal file
51
test/pom.xml
Normal file
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>hxuanyu-spring-boot-starter-parent</artifactId>
|
||||
<groupId>com.hxuanyu</groupId>
|
||||
<version>1.0.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>test</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<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>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>2.8.2</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
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>
|
||||
Reference in New Issue
Block a user