Commit 8dede8f5 authored by fangxinjiang's avatar fangxinjiang

邮件服务

parent 88d75ebc
......@@ -102,6 +102,7 @@
<module>yifu-insurances</module>
<module>yifu-salary</module>
<module>yifu-order</module>
<module>yifu-mail</module>
</modules>
<dependencyManagement>
......
# 忽略匹配下列规则的Git 提交 V2.1.0
### gradle ###
.gradle
/build/
!gradle/wrapper/gradle-wrapper.jar
### STS ###
.settings/
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
bin/
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
*.lock
rebel.xml
### NetBeans ###
nbproject/private/
build/
nbbuild/
nbdist/
.nb-gradle/
### maven ###
target/
*.war
*.ear
*.zip
*.tar
*.tar.gz
### logs ####
/logs/
*.log
### temp ignore ###
*.cache
*.diff
*.patch
*.tmp
*.java~
*.properties~
*.xml~
### system ignore ###
.DS_Store
Thumbs.db
Servers
.metadata
upload
gen_code
### node ###
node_modules
<?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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>yifu-mail</artifactId>
<description>邮件服务</description>
<packaging>pom</packaging>
<!--项目子模块-->
<modules>
<module>yifu-mail-api</module>
<module>yifu-mail-biz</module>
</modules>
</project>
<?xml version="1.0"?>
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>yifu-mail-api</artifactId>
<packaging>jar</packaging>
<description>身份证+手机号验证模块</description>
<dependencies>
<!-- core 工具类 -->
<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-core</artifactId>
</dependency>
<!--swagger 注解-->
<!--<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
</dependency>-->
<!--feign 注解依赖-->
<!--<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-openfeign-core</artifactId>
<optional>true</optional>
</dependency>-->
<!--mybatis 依赖-->
<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-mybatis</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
</dependencies>
</project>
package com.yifu.cloud.plus.v1.check.constant;
/**
* @Author fxj
* @Date 2022/6/21
* @Description
* @Version 1.0
*/
public interface ChecksConstants {
String NACOS_CHECK_CONFIG_ERROR="nacos中checks.yaml的配置canCheck未开启!";
String CODE="code";
String DATA="data";
String CODE_200000="200000";
String NO_DATA_RESULT="接口无返回数据";
String MESSAGE="message";
String MESSAGE_INFO = ",msg:";
String MOBILE="mobile";
String AREA="area";
String NUMBER_TYPE ="numberType";
String CHARGES_STATUS = "chargesStatus";
String STATUS="status";
String RESULT="result";
String REMARK="remark";
String APP_ID ="appId";
String APP_KEY="appKey";
String MOBILES="mobiles";
String NAME="name";
String ID_NUM="idNum";
String CARD_NO="cardNo";
}
package com.yifu.cloud.plus.v1.check.utils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpStatus;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.RequestBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import java.nio.charset.Charset;
import java.util.Map;
/**
* @author hgw2
* @description 发送
* @date 2022/5/7
*/
public class HttpUtils {
private static final int REQUEST_TIMEOUT = 3 * 1000; // 设置请求超时10秒钟
private static final int CONNECT_TIMEOUT = 5 * 1000; // 连接超时时间
private static final int SO_TIMEOUT = 10 * 1000; // 数据传输超时
private static final String ENCODING = "UTF-8";
// 务必单例
private static CloseableHttpClient client;
static {
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(CONNECT_TIMEOUT)
.setConnectionRequestTimeout(REQUEST_TIMEOUT)
.setSocketTimeout(SO_TIMEOUT)
.build();
client = HttpClients.custom().setDefaultRequestConfig(requestConfig).setMaxConnTotal(50).build();
}
public static String get(String url, Map<String, String> paramsMap) {
return send(RequestBuilder.get(url), paramsMap);
}
public static String post(String url, Map<String, String> paramsMap) {
return send(RequestBuilder.post(url), paramsMap);
}
public static String send(RequestBuilder requestBuilder, Map<String, String> paramsMap) {
requestBuilder.setCharset(Charset.forName(ENCODING));
String responseText = "";
if (paramsMap != null) {
for (Map.Entry<String, String> param : paramsMap.entrySet()) {
requestBuilder.addParameter(param.getKey(), param.getValue());
}
CloseableHttpResponse response = null;
try {
response = client.execute(requestBuilder.build());
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
HttpEntity entity = response.getEntity();
if (entity != null) {
responseText = EntityUtils.toString(entity, ENCODING);
}
}
} catch (Exception e) {
e.printStackTrace();//正式项目中请改为log打印
} finally {
try {
response.close();
} catch (Exception e) {
e.printStackTrace();//正式项目中请改为log打印
}
}
}
return responseText;
}
}
package com.yifu.cloud.plus.v1.mail.utils;
/**
* @author hgw2
* @description 测试身份证
* @date 2022/5/7
*/
public class MailUtil {
}
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.yifu.cloud.plus.v1.mail.utils.MailUtil
\ No newline at end of file
FROM moxm/java:1.8-full
RUN mkdir -p /yifu-mail-biz
WORKDIR yifu-mail-biz
ARG JAR_FILE=target/yifu-mail-biz.jar
COPY ${JAR_FILE} app.jar
EXPOSE 5022
ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom"
CMD sleep 60; java -jar app.jar $JAVA_OPTS
#!/usr/bin/env bash
mvn clean package -Pprd -Dmaven.test.skip=true docker:build -DpushImage
\ No newline at end of file
#!/usr/bin/env bash
mvn clean package -Ptest -Dmaven.test.skip=true docker:build -DpushImage
\ No newline at end of file
#!/usr/bin/env bash
mvn clean package -Dmaven.test.skip=true docker:build -DpushImage
\ No newline at end of file
<?xml version="1.0"?>
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>yifu-mail-biz</artifactId>
<packaging>jar</packaging>
<description>身份证+手机号验证模块</description>
<dependencies>
<!--选配: 依赖seata模块-->
<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-seata</artifactId>
</dependency>
<!-- email -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
<version>2.6.7</version>
</dependency>
<!--必备: 依赖api模块-->
<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-mail-api</artifactId>
<version>1.0.0</version>
</dependency>
<!--必备:安全模块-->
<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-security</artifactId>
</dependency>
<!--必备:日志处理-->
<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-log</artifactId>
</dependency>
<!--必备:swagger-->
<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-swagger</artifactId>
</dependency>
<!--必备:undertow容器-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.1.0</version>
<configuration>
<serverId>docker-hub</serverId>
<!--指定生成的镜像名-->
<imageName>${my.hub.host}/${map.group.name}/${project.artifactId}:${project.version}</imageName>
<dockerDirectory>${project.basedir}/</dockerDirectory>
<!--指定远程 docker api地址-->
<!--<dockerHost>http://172.16.66.232:2375</dockerHost>-->
<!-- 这里是复制 jar 包到 docker 容器指定目录配置-->
<resources>
<resource>
<targetPath>/</targetPath>
<!--jar 包所在的路径 此处配置的 即对应 target 目录-->
<directory>${project.build.directory}</directory>
<!-- 需要包含的 jar包 ,这里对应的是 Dockerfile中添加的文件名 -->
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
<forceTags>true</forceTags>
</configuration>
</plugin>
</plugins>
</build>
</project>
package com.yifu.cloud.plus.v1.mail;
import com.yifu.cloud.plus.v1.yifu.common.security.annotation.EnableYifuResourceServer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author pig archetype
* <p>
* 项目启动类
*/
@EnableYifuResourceServer
@SpringBootApplication
public class MailApplication {
public static void main(String[] args) {
SpringApplication.run(MailApplication.class, args);
}
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.mail.controller;
import com.yifu.cloud.plus.v1.mail.service.MailService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
/**
* @Author fxj
* @Description 邮件发送服务
* @Date 17:39 2022/12/1
**/
@RestController
@RequiredArgsConstructor
@RequestMapping("/mail" )
@Tag(name = "邮件发送服务")
public class MailController {
private final MailService mailService;
/**
* 邮件发送服务
* @return
*/
/* @Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page" )
public R getTCheckMobilePage(Page page, TCheckMobile tCheckMobile) {
return R.ok(tCheckMobileService.page(page, Wrappers.query(tCheckMobile)));
}
*/
}
package com.yifu.cloud.plus.v1.mail.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.sun.xml.internal.ws.resources.SenderMessages;
/**
* @Author fxj
* @Description
* @Date 17:38 2022/12/1
* @Param
* @return
**/
public interface MailService {
Boolean sendMail(SenderMessages messages);
}
package com.yifu.cloud.plus.v1.mail.service.impl;
import com.sun.xml.internal.ws.resources.SenderMessages;
import com.yifu.cloud.plus.v1.mail.service.MailService;
import org.springframework.stereotype.Service;
/**
* @Author fxj
* @Description 邮件发送服务
* @Date 17:41 2022/12/1
**/
@Service("mailService")
public class MailServiceImpl implements MailService {
@Override
public Boolean sendMail(SenderMessages messages) {
return null;
}
}
# 数据源配置
spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher
config:
activate:
on-profile: dev
redis:
host: 127.0.0.1
password: '@yf_2017'
mail:
host: smtp.exmail.qq.com
port: 465
username: information@wanxin-holdings.com
password: QmdCaQSPmCAQEddd
protocol: smtp
default-encoding: UTF-8
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: yf_zsk
url: jdbc:mysql://192.168.1.65:22306/yifu_mail?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
hikari:
driver-class-name: ${spring.datasource.driver-class-name}
jdbc-url: ${spring.datasource.url}
username: ${spring.datasource.username}
password: ${spring.datasource.password}
pool-name: AmytangHikariCP
minimum-idle: 10 # 最小空闲连接数量
idle-timeout: 60000 # 空闲连接存活最大时间,默认600000(10分钟)
maximum-pool-size: 12 # 连接池最大连接数,默认是10
auto-commit: true #此属性控制从池返回的连接的默认自动提交行为,默认值:true
max-lifetime: 0 #此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟
## spring security 配置
security:
oauth2:
resource:
loadBalanced: true
token-info-uri: http://127.0.0.1:3000/oauth/check_token
# 直接放行URL
ignore:
urls:
- /v3/api-docs
- /actuator/**
- /swagger-ui/**
\ No newline at end of file
# 数据源配置
spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher
config:
activate:
on-profile: test
redis:
host: 192.168.1.65
port: 22379
password: '@yf_2017'
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: yf_zsk
url: jdbc:mysql://192.168.1.65:22306/yifu_job?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
hikari:
driver-class-name: ${spring.datasource.driver-class-name}
jdbc-url: ${spring.datasource.url}
username: ${spring.datasource.username}
password: ${spring.datasource.password}
pool-name: AmytangHikariCP
minimum-idle: 10 # 最小空闲连接数量
idle-timeout: 60000 # 空闲连接存活最大时间,默认600000(10分钟)
maximum-pool-size: 12 # 连接池最大连接数,默认是10
auto-commit: true #此属性控制从池返回的连接的默认自动提交行为,默认值:true
max-lifetime: 0 #此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟
## spring security 配置
security:
oauth2:
resource:
loadBalanced: true
token-info-uri: http://127.0.0.1:3000/oauth/check_token
# 直接放行URL
ignore:
urls:
- /v3/api-docs
- /actuator/**
- /swagger-ui/**
\ No newline at end of file
server:
port: 5024
# 加解密根密码
jasypt:
encryptor:
password: yifu #根密码
# 暴露监控端点
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: ALWAYS
# mybaits-plus配置
mybatis-plus:
mapper-locations: classpath:/mapper/*Mapper.xml
global-config:
banner: false
db-config:
id-type: auto
table-underline: true
logic-delete-value: 1
logic-not-delete-value: 0
configuration:
map-underscore-to-camel-case: true
spring:
application:
name: @artifactId@
#swagger 文档 https://springdoc.org/
### OpenAPI3 注解
# OpenAPI 3 注解位置
# @Tag(name = “接口类描述”) Controller 类上
# @Operation(summary =“接口方法描述”) Controller 方法上
# @Parameters Controller 方法上
# @Parameter(description=“参数描述”) Controller 方法上 @Parameters 里
# @Parameter(description=“参数描述”) Controller 方法的参数上
# @Parameter(hidden = true) 或 @Hidden --
# @Schema DTO类上
# @Schema DTO属性上
springdoc:
api-docs:
#是否开启文档功能
enabled: true
#swagger后端请求地址
path: /api-docs
swagger-ui:
#自定义swagger前端请求路径,输入http:127.0.0.1:8080/test会自动重定向到swagger页面
path: /api
#包扫描路径
packages-to-scan: com.yifu.cloud.plus.v1.mail.controller
#这里定义了两个分组,可定义多个,也可以不定义
group-configs:
#分组名
#- group: admin
#按路径匹配
# pathsToMatch: /admin/**
#分组名
- group: mail
#按包路径匹配
packagesToScan: com.yifu.cloud.plus.v1.mail.controller
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false" scan="false">
<springProperty scop="context" name="spring.application.name" source="spring.application.name" defaultValue=""/>
<property name="log.path" value="logs/${spring.application.name}"/>
<!-- 彩色日志格式 -->
<property name="CONSOLE_LOG_PATTERN"
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
<!-- 彩色日志依赖的渲染类 -->
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
<conversionRule conversionWord="wex"
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
<conversionRule conversionWord="wEx"
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
<!-- Console log output -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- Log file debug output -->
<appender name="debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/debug.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/%d{yyyy-MM, aux}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
</encoder>
</appender>
<!-- Log file error output -->
<appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
</appender>
<!-- Level: FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 -->
<root level="INFO">
<appender-ref ref="console"/>
<appender-ref ref="debug"/>
<appender-ref ref="error"/>
</root>
</configuration>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment