init workflow project
This commit is contained in:
commit
6384c997ad
38
.gitignore
vendored
Normal file
38
.gitignore
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea/modules.xml
|
||||||
|
.idea/jarRepositories.xml
|
||||||
|
.idea/compiler.xml
|
||||||
|
.idea/libraries/
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
|
.DS_Store
|
||||||
10
.idea/.gitignore
vendored
Normal file
10
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# 默认忽略的文件
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# 基于编辑器的 HTTP 客户端请求
|
||||||
|
/httpRequests/
|
||||||
|
# 依赖于环境的 Maven 主目录路径
|
||||||
|
/mavenHomeManager.xml
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
7
.idea/encodings.xml
Normal file
7
.idea/encodings.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding">
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
14
.idea/misc.xml
Normal file
14
.idea/misc.xml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="MavenProjectsManager">
|
||||||
|
<option name="originalFiles">
|
||||||
|
<list>
|
||||||
|
<option value="$PROJECT_DIR$/pom.xml" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="OpenJDK17" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
118
pom.xml
Normal file
118
pom.xml
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>3.5.0</version>
|
||||||
|
<relativePath/>
|
||||||
|
</parent>
|
||||||
|
<groupId>asia.yulinling</groupId>
|
||||||
|
<artifactId>workflow</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<name>workflow</name>
|
||||||
|
<description>Demo project for Spring Boot</description>
|
||||||
|
<url/>
|
||||||
|
<licenses>
|
||||||
|
<license/>
|
||||||
|
</licenses>
|
||||||
|
<developers>
|
||||||
|
<developer/>
|
||||||
|
</developers>
|
||||||
|
<scm>
|
||||||
|
<connection/>
|
||||||
|
<developerConnection/>
|
||||||
|
<tag/>
|
||||||
|
<url/>
|
||||||
|
</scm>
|
||||||
|
<properties>
|
||||||
|
<java.version>17</java.version>
|
||||||
|
<mail.version>1.6.2</mail.version>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!--jasypt配置文件加解密-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.ulisesbocchio</groupId>
|
||||||
|
<artifactId>jasypt-spring-boot-starter</artifactId>
|
||||||
|
<version>2.1.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-mail</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-all</artifactId>
|
||||||
|
<version>5.8.38</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sun.mail</groupId>
|
||||||
|
<artifactId>javax.mail</artifactId>
|
||||||
|
<version>${mail.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-devtools</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<annotationProcessorPaths>
|
||||||
|
<path>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</path>
|
||||||
|
</annotationProcessorPaths>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<excludes>
|
||||||
|
<exclude>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</exclude>
|
||||||
|
</excludes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
12
src/main/java/asia/yulinling/workflow/WorkFlowMain.java
Normal file
12
src/main/java/asia/yulinling/workflow/WorkFlowMain.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package asia.yulinling.workflow;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
public class WorkFlowMain {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(WorkFlowMain.class, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,59 @@
|
|||||||
|
package asia.yulinling.workflow.service;
|
||||||
|
|
||||||
|
import javax.mail.MessagingException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 邮件接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author yulinling
|
||||||
|
* @date Create in 2025/6/3 22:49
|
||||||
|
*/
|
||||||
|
public interface MailService {
|
||||||
|
/**
|
||||||
|
* 发送文本邮件
|
||||||
|
*
|
||||||
|
* @param to 收件人地址
|
||||||
|
* @param subject 邮件主题
|
||||||
|
* @param content 邮件内容
|
||||||
|
* @param cc 抄送地址
|
||||||
|
*/
|
||||||
|
void sendSimpleMail(String to, String subject, String content, String... cc);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送HTML邮件
|
||||||
|
*
|
||||||
|
* @param to 收件人地址
|
||||||
|
* @param subject 邮件主题
|
||||||
|
* @param content 邮件内容
|
||||||
|
* @param cc 抄送地址
|
||||||
|
* @throws MessagingException 邮件发送异常
|
||||||
|
*/
|
||||||
|
void sendHtmlMail(String to, String subject, String content, String... cc) throws MessagingException;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送带附件邮件
|
||||||
|
*
|
||||||
|
* @param to 收件人地址
|
||||||
|
* @param subject 邮件主题
|
||||||
|
* @param content 邮件内容
|
||||||
|
* @param filePath 附件地址
|
||||||
|
* @param cc 抄送地址
|
||||||
|
* @throws MessagingException 邮件发送异常
|
||||||
|
*/
|
||||||
|
void sendAttachmentsMail(String to, String subject, String content, String filePath, String... cc) throws MessagingException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送带附件邮件
|
||||||
|
*
|
||||||
|
* @param to 收件人地址
|
||||||
|
* @param subject 邮件主题
|
||||||
|
* @param content 邮件内容
|
||||||
|
* @param rscPath 静态资源地址
|
||||||
|
* @param cc 抄送地址
|
||||||
|
* @throws MessagingException 邮件发送异常
|
||||||
|
*/
|
||||||
|
void sendResourceMail(String to, String subject, String content, String rscPath, String... cc) throws MessagingException;
|
||||||
|
}
|
||||||
@ -0,0 +1,92 @@
|
|||||||
|
package asia.yulinling.workflow.service.impl;
|
||||||
|
|
||||||
|
import asia.yulinling.workflow.service.MailService;
|
||||||
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.mail.SimpleMailMessage;
|
||||||
|
import org.springframework.mail.javamail.JavaMailSender;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.mail.MessagingException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 邮件接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author yulinling
|
||||||
|
* @date Create in 2025/6/3 22:49
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class MailServiceImpl implements MailService {
|
||||||
|
|
||||||
|
private final JavaMailSender mailSender;
|
||||||
|
@Value("${spring.mail.username}")
|
||||||
|
private String from;
|
||||||
|
/**
|
||||||
|
* 发送文本邮件
|
||||||
|
*
|
||||||
|
* @param to 收件人地址
|
||||||
|
* @param subject 邮件主题
|
||||||
|
* @param content 邮件内容
|
||||||
|
* @param cc 抄送地址
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void sendSimpleMail(String to, String subject, String content, String... cc) {
|
||||||
|
SimpleMailMessage message = new SimpleMailMessage();
|
||||||
|
message.setFrom(from);
|
||||||
|
message.setTo(to);
|
||||||
|
message.setSubject(subject);
|
||||||
|
message.setText(content);
|
||||||
|
if (ArrayUtil.isNotEmpty(cc)) {
|
||||||
|
message.setCc(cc);
|
||||||
|
}
|
||||||
|
mailSender.send(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送HTML邮件
|
||||||
|
*
|
||||||
|
* @param to 收件人地址
|
||||||
|
* @param subject 邮件主题
|
||||||
|
* @param content 邮件内容
|
||||||
|
* @param cc 抄送地址
|
||||||
|
* @throws MessagingException 邮件发送异常
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void sendHtmlMail(String to, String subject, String content, String... cc) throws MessagingException {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送带附件邮件
|
||||||
|
*
|
||||||
|
* @param to 收件人地址
|
||||||
|
* @param subject 邮件主题
|
||||||
|
* @param content 邮件内容
|
||||||
|
* @param filePath 附件地址
|
||||||
|
* @param cc 抄送地址
|
||||||
|
* @throws MessagingException 邮件发送异常
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void sendAttachmentsMail(String to, String subject, String content, String filePath, String... cc) throws MessagingException {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送带附件邮件
|
||||||
|
*
|
||||||
|
* @param to 收件人地址
|
||||||
|
* @param subject 邮件主题
|
||||||
|
* @param content 邮件内容
|
||||||
|
* @param rscPath 静态资源地址
|
||||||
|
* @param cc 抄送地址
|
||||||
|
* @throws MessagingException 邮件发送异常
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void sendResourceMail(String to, String subject, String content, String rscPath, String... cc) throws MessagingException {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
23
src/main/resources/application.yml
Normal file
23
src/main/resources/application.yml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
spring:
|
||||||
|
mail:
|
||||||
|
host: smtp.qq.com
|
||||||
|
port: 587
|
||||||
|
username: 2712495353@qq.com
|
||||||
|
# 使用 jasypt 加密密码,使用com.xkcoding.email.PasswordTest.testGeneratePassword 生成加密密码,替换 ENC(加密密码)
|
||||||
|
# password: ENC(OT0qGOpXrr1Iog1W+fjOiIDCJdBjHyhy)
|
||||||
|
password: xlwpmlbawpjjdghb
|
||||||
|
protocol: smtp
|
||||||
|
test-connection: false
|
||||||
|
default-encoding: UTF-8
|
||||||
|
properties:
|
||||||
|
mail.smtp.auth: true
|
||||||
|
mail.smtp.starttls.enable: true
|
||||||
|
mail.smtp.starttls.required: true
|
||||||
|
mail.smtp.ssl.enable: false
|
||||||
|
mail.display.sendmail: spring-boot-demo
|
||||||
|
# 为 jasypt 配置解密秘钥
|
||||||
|
jasypt:
|
||||||
|
encryptor:
|
||||||
|
bean: jasyptStringEncryptor
|
||||||
|
password: spring-boot-demo
|
||||||
|
algorithm: PBEWITHHMACSHA512ANDAES_256
|
||||||
29
src/test/java/asia/yulinling/workflow/PasswordTest.java
Normal file
29
src/test/java/asia/yulinling/workflow/PasswordTest.java
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package asia.yulinling.workflow;
|
||||||
|
|
||||||
|
import org.jasypt.encryption.StringEncryptor;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密码加密测试
|
||||||
|
*/
|
||||||
|
public class PasswordTest extends WorkFlowMainTests {
|
||||||
|
@Autowired
|
||||||
|
private StringEncryptor encryptor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成加密密码
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGeneratePassword() {
|
||||||
|
// 你的邮箱密码
|
||||||
|
String password = "Just4Test!";
|
||||||
|
// 加密后的密码(注意:配置上去的时候需要加 ENC(加密密码))
|
||||||
|
String encryptPassword = encryptor.encrypt(password);
|
||||||
|
String decryptPassword = encryptor.decrypt(encryptPassword);
|
||||||
|
|
||||||
|
System.out.println("password = " + password);
|
||||||
|
System.out.println("encryptPassword = " + encryptPassword);
|
||||||
|
System.out.println("decryptPassword = " + decryptPassword);
|
||||||
|
}
|
||||||
|
}
|
||||||
18
src/test/java/asia/yulinling/workflow/WorkFlowMainTests.java
Normal file
18
src/test/java/asia/yulinling/workflow/WorkFlowMainTests.java
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package asia.yulinling.workflow;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
public class WorkFlowMainTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void contextLoads() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user