邮件模块 删除mail-module
parent
0b0e37a3d5
commit
ea92b84121
@ -1,65 +0,0 @@
|
|||||||
<?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>
|
|
||||||
<groupId>cn.iocoder.boot</groupId>
|
|
||||||
<artifactId>yudao-framework</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<artifactId>yudao-spring-boot-starter-biz-mail</artifactId>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.iocoder.boot</groupId>
|
|
||||||
<artifactId>yudao-common</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Spring 核心 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 监控相关 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.opentracing</groupId>
|
|
||||||
<artifactId>opentracing-util</artifactId> <!-- aliyun 短信需要,进行链路追踪 -->
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Test 测试相关 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.iocoder.boot</groupId>
|
|
||||||
<artifactId>yudao-spring-boot-starter-test</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 工具类相关 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.guava</groupId>
|
|
||||||
<artifactId>guava</artifactId>
|
|
||||||
<optional>true</optional> <!-- 设置为可选,因为使用到 @VisibleForTesting 用于单元测试 -->
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-databind</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-core</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>jakarta.validation</groupId>
|
|
||||||
<artifactId>jakarta.validation-api</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
package cn.iocoder.yudao.framework.mail.config;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.mail.core.client.MailClientFactory;
|
|
||||||
import cn.iocoder.yudao.framework.mail.core.client.impl.MailClientFactoryImpl;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 邮箱配置类
|
|
||||||
*
|
|
||||||
* @author 芋道源码
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class YudaoMailAutoConfiguration {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public MailClientFactory mailClientFactory() {
|
|
||||||
return new MailClientFactoryImpl();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
package cn.iocoder.yudao.framework.mail.core.client;
|
|
||||||
|
|
||||||
public interface MailClientFactory {
|
|
||||||
MailClient getMailClient();
|
|
||||||
}
|
|
||||||
@ -1,48 +0,0 @@
|
|||||||
package cn.iocoder.yudao.framework.mail.core.client.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 消息接收 Response DTO
|
|
||||||
*
|
|
||||||
* @author 芋道源码
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class MailReceiveRespDTO {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否接收成功
|
|
||||||
*/
|
|
||||||
private Boolean success;
|
|
||||||
/**
|
|
||||||
* API 接收结果的编码
|
|
||||||
*/
|
|
||||||
private String errorCode;
|
|
||||||
/**
|
|
||||||
* API 接收结果的说明
|
|
||||||
*/
|
|
||||||
private String errorMsg;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 手机号
|
|
||||||
*/
|
|
||||||
private String mobile;
|
|
||||||
/**
|
|
||||||
* 用户接收时间
|
|
||||||
*/
|
|
||||||
private Date receiveTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 短信 API 发送返回的序号
|
|
||||||
*/
|
|
||||||
private String serialNo;
|
|
||||||
/**
|
|
||||||
* 短信日志编号
|
|
||||||
*
|
|
||||||
* 对应 SysSmsLogDO 的编号
|
|
||||||
*/
|
|
||||||
private Long logId;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
package cn.iocoder.yudao.framework.mail.core.client.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 短信发送 Response DTO
|
|
||||||
*
|
|
||||||
* @author 芋道源码
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class MailSendRespDTO {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 短信 API 发送返回的序号
|
|
||||||
*/
|
|
||||||
private String serialNo;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,31 +0,0 @@
|
|||||||
package cn.iocoder.yudao.framework.mail.core.client.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 短信模板 Response DTO
|
|
||||||
*
|
|
||||||
* @author 芋道源码
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class MailTemplateRespDTO {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 模板编号
|
|
||||||
*/
|
|
||||||
private String id;
|
|
||||||
/**
|
|
||||||
* 短信内容
|
|
||||||
*/
|
|
||||||
private String content;
|
|
||||||
/**
|
|
||||||
* 审核状态
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private Integer auditStatus;
|
|
||||||
/**
|
|
||||||
* 审核未通过的理由
|
|
||||||
*/
|
|
||||||
private String auditReason;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,39 +0,0 @@
|
|||||||
package cn.iocoder.yudao.framework.mail.core.client.impl;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.mail.core.client.MailClient;
|
|
||||||
import cn.iocoder.yudao.framework.mail.core.client.impl.hutool.HutoolMailClient;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import cn.iocoder.yudao.framework.mail.core.client.MailClientFactory;
|
|
||||||
import cn.iocoder.yudao.framework.mail.core.enums.MailChannelEnum;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.concurrent.ConcurrentMap;
|
|
||||||
@Validated
|
|
||||||
@Slf4j
|
|
||||||
public class MailClientFactoryImpl implements MailClientFactory {
|
|
||||||
|
|
||||||
private final ConcurrentMap<String, AbstractMailClient> channelCodeClients = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
public MailClientFactoryImpl (){
|
|
||||||
Arrays.stream(MailChannelEnum.values()).forEach(mailChannelEnum -> {
|
|
||||||
AbstractMailClient abstractMailClient = createMailClient(mailChannelEnum);
|
|
||||||
channelCodeClients.put(mailChannelEnum.getCode() , abstractMailClient);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private AbstractMailClient createMailClient(MailChannelEnum mailChannelEnum) {
|
|
||||||
switch (mailChannelEnum){
|
|
||||||
case HUTOOL: return new HutoolMailClient();
|
|
||||||
}
|
|
||||||
// 创建失败,错误日志 + 抛出异常
|
|
||||||
log.error("[createMailClient][配置({}) 找不到合适的客户端实现]" , mailChannelEnum);
|
|
||||||
throw new IllegalArgumentException(String.format("配置(%s) 找不到合适的客户端实现", mailChannelEnum));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MailClient getMailClient() {
|
|
||||||
return channelCodeClients.get("HUTOOL");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,29 +0,0 @@
|
|||||||
package cn.iocoder.yudao.framework.mail.core.client.impl.hutool;
|
|
||||||
|
|
||||||
import cn.hutool.extra.mail.MailUtil;
|
|
||||||
import cn.iocoder.yudao.framework.mail.core.client.impl.AbstractMailClient;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 邮件客户端实现
|
|
||||||
*
|
|
||||||
* @author wangjingyi
|
|
||||||
* @date 2021/4/25 14:25
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
public class HutoolMailClient extends AbstractMailClient {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String sendMail(String from, String content, String title, List<String> tos) {
|
|
||||||
try{
|
|
||||||
return MailUtil.send(from , title , content , false , null);
|
|
||||||
}catch (Exception e){
|
|
||||||
log.error(e.getMessage());
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,20 +0,0 @@
|
|||||||
package cn.iocoder.yudao.framework.mail.core.client.impl.hutool;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
|
||||||
import cn.iocoder.yudao.framework.mail.core.client.MailCodeMapping;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 阿里云的 SmsCodeMapping 实现类
|
|
||||||
*
|
|
||||||
* 参见 https://help.aliyun.com/document_detail/101346.htm 文档
|
|
||||||
*
|
|
||||||
* @author 芋道源码
|
|
||||||
*/
|
|
||||||
public class HutoolMailCodeMapping implements MailCodeMapping {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ErrorCode apply(String apiCode) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
package cn.iocoder.yudao.framework.mail.core.enums;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 短信渠道枚举
|
|
||||||
*
|
|
||||||
* @author zzf
|
|
||||||
* @date 2021/1/25 10:56
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@AllArgsConstructor
|
|
||||||
public enum MailChannelEnum {
|
|
||||||
HUTOOL("HUTOOL" , "HUTOOL"),
|
|
||||||
;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 编码
|
|
||||||
*/
|
|
||||||
private final String code;
|
|
||||||
/**
|
|
||||||
* 名字
|
|
||||||
*/
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
public static MailChannelEnum getByCode(String code) {
|
|
||||||
return ArrayUtil.firstMatch(o -> o.getCode().equals(code), values());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
package cn.iocoder.yudao.framework.mail.core.enums;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 短信模板的审核状态枚举
|
|
||||||
*
|
|
||||||
* @author 芋道源码
|
|
||||||
*/
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Getter
|
|
||||||
public enum MailTemplateAuditStatusEnum {
|
|
||||||
|
|
||||||
CHECKING(1),
|
|
||||||
SUCCESS(2),
|
|
||||||
FAIL(3);
|
|
||||||
|
|
||||||
private final Integer status;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,52 +0,0 @@
|
|||||||
package cn.iocoder.yudao.framework.mail.core.property;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import cn.iocoder.yudao.framework.mail.core.enums.MailChannelEnum;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 短信渠道配置类
|
|
||||||
*
|
|
||||||
* @author zzf
|
|
||||||
* @date 2021/1/25 17:01
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Validated
|
|
||||||
public class MailChannelProperties {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 渠道编号
|
|
||||||
*/
|
|
||||||
@NotNull(message = "短信渠道 ID 不能为空")
|
|
||||||
private Long id;
|
|
||||||
/**
|
|
||||||
* 短信签名
|
|
||||||
*/
|
|
||||||
@NotEmpty(message = "短信签名不能为空")
|
|
||||||
private String signature;
|
|
||||||
/**
|
|
||||||
* 渠道编码
|
|
||||||
*
|
|
||||||
* 枚举 {@link MailChannelEnum}
|
|
||||||
*/
|
|
||||||
@NotEmpty(message = "渠道编码不能为空")
|
|
||||||
private String code;
|
|
||||||
/**
|
|
||||||
* 短信 API 的账号
|
|
||||||
*/
|
|
||||||
@NotEmpty(message = "短信 API 的账号不能为空")
|
|
||||||
private String apiKey;
|
|
||||||
/**
|
|
||||||
* 短信 API 的秘钥
|
|
||||||
*/
|
|
||||||
@NotEmpty(message = "短信 API 的秘钥不能为空")
|
|
||||||
private String apiSecret;
|
|
||||||
/**
|
|
||||||
* 短信发送回调 URL
|
|
||||||
*/
|
|
||||||
private String callbackUrl;
|
|
||||||
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue