Skip to content

Commit 2daf9ed

Browse files
committed
ApiBoot Mail 初版发布
1 parent 707d82d commit 2daf9ed

File tree

20 files changed

+940
-2
lines changed

20 files changed

+940
-2
lines changed

api-boot-project/api-boot-autoconfigure/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,5 +194,12 @@
194194
<optional>true</optional>
195195
</dependency>
196196

197+
<!--ApiBoot Mail-->
198+
<dependency>
199+
<groupId>org.minbox.framework</groupId>
200+
<artifactId>api-boot-plugin-mail</artifactId>
201+
<optional>true</optional>
202+
</dependency>
203+
197204
</dependencies>
198205
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Copyright [2019] [恒宇少年 - 于起宇]
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
package org.minbox.framework.api.boot.autoconfigure.mail;
19+
20+
import com.aliyuncs.DefaultAcsClient;
21+
import com.aliyuncs.IAcsClient;
22+
import com.aliyuncs.profile.DefaultProfile;
23+
import com.aliyuncs.profile.IClientProfile;
24+
import org.minbox.framework.api.boot.plugin.mail.ApiBootAliYunMailService;
25+
import org.minbox.framework.api.boot.plugin.mail.ApiBootMailService;
26+
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
27+
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
28+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
29+
import org.springframework.boot.context.properties.EnableConfigurationProperties;
30+
import org.springframework.context.annotation.Bean;
31+
import org.springframework.context.annotation.Configuration;
32+
33+
import static org.minbox.framework.api.boot.autoconfigure.mail.ApiBootMailProperties.API_BOOT_MAIL_PREFIX;
34+
35+
/**
36+
* ApiBoot Mail Auto Configuration
37+
*
38+
* @author:恒宇少年 - 于起宇
39+
* <p>
40+
* DateTime:2019-06-19 18:41
41+
* Blog:http://blog.yuqiyu.com
42+
* WebSite:http://www.jianshu.com/u/092df3f77bca
43+
* Gitee:https://gitee.com/hengboy
44+
* GitHub:https://github.com/hengboy
45+
*/
46+
@Configuration
47+
@ConditionalOnClass(ApiBootAliYunMailService.class)
48+
@ConditionalOnProperty(prefix = API_BOOT_MAIL_PREFIX, name = {"access-key", "access-secret", "account-name", "region"})
49+
@EnableConfigurationProperties(ApiBootMailProperties.class)
50+
public class ApiBootMailAutoConfiguration {
51+
/**
52+
* ApiBoot Mail Properties
53+
*/
54+
private ApiBootMailProperties apiBootMailProperties;
55+
56+
public ApiBootMailAutoConfiguration(ApiBootMailProperties apiBootMailProperties) {
57+
this.apiBootMailProperties = apiBootMailProperties;
58+
}
59+
60+
/**
61+
* ApiBoot Mail Service AliYun Support
62+
*
63+
* @return ApiBootMailService Support Instance
64+
*/
65+
@Bean
66+
@ConditionalOnMissingBean
67+
public ApiBootMailService apiBootMailService(IAcsClient acsClient) {
68+
return new ApiBootAliYunMailService(acsClient, apiBootMailProperties.getAccountName(), apiBootMailProperties.isReplyToAddress(), apiBootMailProperties.getAddressType(), apiBootMailProperties.getFromAlias(), apiBootMailProperties.getTagName());
69+
}
70+
71+
/**
72+
* Instance AliYun Acs Client
73+
*
74+
* @return IAcsClient Support Instance
75+
* @see DefaultProfile
76+
* @see DefaultAcsClient
77+
*/
78+
@Bean
79+
@ConditionalOnMissingBean
80+
public IAcsClient acsClient() {
81+
IClientProfile profile = DefaultProfile.getProfile(apiBootMailProperties.getRegion().getValue(), apiBootMailProperties.getAccessKey(), apiBootMailProperties.getAccessSecret());
82+
return new DefaultAcsClient(profile);
83+
}
84+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright [2019] [恒宇少年 - 于起宇]
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
package org.minbox.framework.api.boot.autoconfigure.mail;
19+
20+
import lombok.Data;
21+
import org.minbox.framework.api.boot.plugin.mail.MailRegion;
22+
import org.springframework.boot.context.properties.ConfigurationProperties;
23+
import org.springframework.context.annotation.Configuration;
24+
25+
import static org.minbox.framework.api.boot.autoconfigure.mail.ApiBootMailProperties.API_BOOT_MAIL_PREFIX;
26+
27+
/**
28+
* ApiBoot Mail Properties
29+
*
30+
* @author:恒宇少年 - 于起宇
31+
* <p>
32+
* DateTime:2019-06-19 18:48
33+
* Blog:http://blog.yuqiyu.com
34+
* WebSite:http://www.jianshu.com/u/092df3f77bca
35+
* Gitee:https://gitee.com/hengboy
36+
* GitHub:https://github.com/hengboy
37+
*/
38+
@Configuration
39+
@ConfigurationProperties(prefix = API_BOOT_MAIL_PREFIX)
40+
@Data
41+
public class ApiBootMailProperties {
42+
/**
43+
* ApiBoot mail properties config prefix
44+
*/
45+
public static final String API_BOOT_MAIL_PREFIX = "api.boot.mail";
46+
/**
47+
* AliYun console allocation Access Key
48+
*/
49+
private String accessKey;
50+
/**
51+
* AliYun console allocation Access Secret
52+
*/
53+
private String accessSecret;
54+
/**
55+
* The mail address configured in the management console.
56+
*/
57+
private String accountName;
58+
/**
59+
* Use the reply address configured in the administrative console (status must be validated).
60+
*/
61+
private boolean replyToAddress = true;
62+
/**
63+
* Random accounts range from 0 to 1:0 and addresses from 1.
64+
*/
65+
private int addressType = 1;
66+
/**
67+
* Default From Alias
68+
*/
69+
private String fromAlias = "ApiBootMail";
70+
/**
71+
* Default Tag Name
72+
*/
73+
private String tagName;
74+
/**
75+
* Mail Region
76+
*/
77+
private MailRegion region;
78+
}

api-boot-project/api-boot-autoconfigure/src/main/resources/META-INF/spring.factories

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
1414
org.minbox.framework.api.boot.autoconfigure.push.ApiBootMessagePushAutoConfiguration,\
1515
org.minbox.framework.api.boot.autoconfigure.pageable.ApiBootMybatisPageableAutoConfiguration,\
1616
org.minbox.framework.api.boot.autoconfigure.enhance.ApiBootMyBatisEnhanceAutoConfiguration,\
17-
org.minbox.framework.api.boot.autoconfigure.ratelimiter.ApiBootRateLimiterAutoConfiguration
17+
org.minbox.framework.api.boot.autoconfigure.ratelimiter.ApiBootRateLimiterAutoConfiguration,\
18+
org.minbox.framework.api.boot.autoconfigure.mail.ApiBootMailAutoConfiguration

api-boot-project/api-boot-dependencies/pom.xml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<artifactId>api-boot-dependencies</artifactId>
1515
<properties>
1616
<main.basedir>${basedir}/../..</main.basedir>
17-
<spring.boot.version>2.1.5.RELEASE</spring.boot.version>
17+
<spring.boot.version>2.1.6.RELEASE</spring.boot.version>
1818
<api.boot.version>2.1.0-SNAPSHOT</api.boot.version>
1919
<druid.version>1.1.14</druid.version>
2020
<druid.starter.version>1.1.14</druid.starter.version>
@@ -47,6 +47,7 @@
4747
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
4848
<build-helper-maven-plugin.version>3.0.0</build-helper-maven-plugin.version>
4949

50+
<aliyun-java-sdk-dm.version>3.3.1</aliyun-java-sdk-dm.version>
5051
</properties>
5152
<dependencyManagement>
5253
<dependencies>
@@ -357,6 +358,23 @@
357358
<version>${nacos.config.version}</version>
358359
</dependency>
359360

361+
<!--ApiBoot Mail-->
362+
<dependency>
363+
<groupId>org.minbox.framework</groupId>
364+
<artifactId>api-boot-plugin-mail</artifactId>
365+
<version>${api.boot.version}</version>
366+
</dependency>
367+
<dependency>
368+
<groupId>org.minbox.framework</groupId>
369+
<artifactId>api-boot-starter-mail</artifactId>
370+
<version>${api.boot.version}</version>
371+
</dependency>
372+
<dependency>
373+
<groupId>com.aliyun</groupId>
374+
<artifactId>aliyun-java-sdk-dm</artifactId>
375+
<version>${aliyun-java-sdk-dm.version}</version>
376+
</dependency>
377+
360378
</dependencies>
361379
</dependencyManagement>
362380

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright [2019] [恒宇少年 - 于起宇]
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
~
17+
-->
18+
19+
<project xmlns="http://maven.apache.org/POM/4.0.0"
20+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
22+
<parent>
23+
<artifactId>api-boot-plugins</artifactId>
24+
<groupId>org.minbox.framework</groupId>
25+
<version>2.1.0-SNAPSHOT</version>
26+
</parent>
27+
<modelVersion>4.0.0</modelVersion>
28+
<properties>
29+
<main.basedir>${basedir}/../../..</main.basedir>
30+
</properties>
31+
<description>
32+
集成邮件服务
33+
</description>
34+
<artifactId>api-boot-plugin-mail</artifactId>
35+
<dependencies>
36+
<!--ApiBoot Plugin-->
37+
<dependency>
38+
<groupId>org.minbox.framework</groupId>
39+
<artifactId>api-boot-plugin</artifactId>
40+
</dependency>
41+
<!--aliyun java jdk-->
42+
<dependency>
43+
<groupId>com.aliyun</groupId>
44+
<artifactId>aliyun-java-sdk-core</artifactId>
45+
</dependency>
46+
<dependency>
47+
<groupId>com.aliyun</groupId>
48+
<artifactId>aliyun-java-sdk-dm</artifactId>
49+
</dependency>
50+
51+
</dependencies>
52+
</project>

0 commit comments

Comments
 (0)