Commit ea92b8412173b0ef0c65e30e9cbebcd56e029ed6
1 parent
0b0e37a3
邮件模块 删除mail-module
Showing
22 changed files
with
15 additions
and
574 deletions
yudao-framework/pom.xml
| ... | ... | @@ -30,7 +30,6 @@ |
| 30 | 30 | <module>yudao-spring-boot-starter-biz-operatelog</module> |
| 31 | 31 | <module>yudao-spring-boot-starter-biz-dict</module> |
| 32 | 32 | <module>yudao-spring-boot-starter-biz-sms</module> |
| 33 | - <module>yudao-spring-boot-starter-biz-mail</module> | |
| 34 | 33 | <module>yudao-spring-boot-starter-activiti</module> |
| 35 | 34 | <module>yudao-spring-boot-starter-biz-pay</module> |
| 36 | 35 | <module>yudao-spring-boot-starter-biz-weixin</module> | ... | ... |
yudao-framework/yudao-spring-boot-starter-biz-mail/pom.xml deleted
| 1 | -<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | -<project xmlns="http://maven.apache.org/POM/4.0.0" | |
| 3 | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 4 | - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
| 5 | - <parent> | |
| 6 | - <groupId>cn.iocoder.boot</groupId> | |
| 7 | - <artifactId>yudao-framework</artifactId> | |
| 8 | - <version>${revision}</version> | |
| 9 | - </parent> | |
| 10 | - <modelVersion>4.0.0</modelVersion> | |
| 11 | - <artifactId>yudao-spring-boot-starter-biz-mail</artifactId> | |
| 12 | - <packaging>jar</packaging> | |
| 13 | - | |
| 14 | - <dependencies> | |
| 15 | - <dependency> | |
| 16 | - <groupId>cn.iocoder.boot</groupId> | |
| 17 | - <artifactId>yudao-common</artifactId> | |
| 18 | - </dependency> | |
| 19 | - | |
| 20 | - <!-- Spring 核心 --> | |
| 21 | - <dependency> | |
| 22 | - <groupId>org.springframework.boot</groupId> | |
| 23 | - <artifactId>spring-boot-starter</artifactId> | |
| 24 | - </dependency> | |
| 25 | - | |
| 26 | - <!-- 监控相关 --> | |
| 27 | - <dependency> | |
| 28 | - <groupId>io.opentracing</groupId> | |
| 29 | - <artifactId>opentracing-util</artifactId> <!-- aliyun 短信需要,进行链路追踪 --> | |
| 30 | - </dependency> | |
| 31 | - | |
| 32 | - <!-- Test 测试相关 --> | |
| 33 | - <dependency> | |
| 34 | - <groupId>cn.iocoder.boot</groupId> | |
| 35 | - <artifactId>yudao-spring-boot-starter-test</artifactId> | |
| 36 | - <scope>test</scope> | |
| 37 | - </dependency> | |
| 38 | - | |
| 39 | - <!-- 工具类相关 --> | |
| 40 | - <dependency> | |
| 41 | - <groupId>com.google.guava</groupId> | |
| 42 | - <artifactId>guava</artifactId> | |
| 43 | - <optional>true</optional> <!-- 设置为可选,因为使用到 @VisibleForTesting 用于单元测试 --> | |
| 44 | - </dependency> | |
| 45 | - | |
| 46 | - <dependency> | |
| 47 | - <groupId>com.fasterxml.jackson.core</groupId> | |
| 48 | - <artifactId>jackson-databind</artifactId> | |
| 49 | - </dependency> | |
| 50 | - <dependency> | |
| 51 | - <groupId>com.fasterxml.jackson.core</groupId> | |
| 52 | - <artifactId>jackson-core</artifactId> | |
| 53 | - </dependency> | |
| 54 | - | |
| 55 | - <dependency> | |
| 56 | - <groupId>jakarta.validation</groupId> | |
| 57 | - <artifactId>jakarta.validation-api</artifactId> | |
| 58 | - </dependency> | |
| 59 | - <dependency> | |
| 60 | - <groupId>org.projectlombok</groupId> | |
| 61 | - <artifactId>lombok</artifactId> | |
| 62 | - </dependency> | |
| 63 | - </dependencies> | |
| 64 | - | |
| 65 | -</project> | |
| 66 | 0 | \ No newline at end of file |
yudao-framework/yudao-spring-boot-starter-biz-mail/src/main/java/cn/iocoder/yudao/framework/mail/config/YudaoMailAutoConfiguration.java deleted
| 1 | -package cn.iocoder.yudao.framework.mail.config; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.mail.core.client.MailClientFactory; | |
| 4 | -import cn.iocoder.yudao.framework.mail.core.client.impl.MailClientFactoryImpl; | |
| 5 | -import org.springframework.context.annotation.Bean; | |
| 6 | -import org.springframework.context.annotation.Configuration; | |
| 7 | - | |
| 8 | -/** | |
| 9 | - * 邮箱配置类 | |
| 10 | - * | |
| 11 | - * @author 芋道源码 | |
| 12 | - */ | |
| 13 | -@Configuration | |
| 14 | -public class YudaoMailAutoConfiguration { | |
| 15 | - | |
| 16 | - @Bean | |
| 17 | - public MailClientFactory mailClientFactory() { | |
| 18 | - return new MailClientFactoryImpl(); | |
| 19 | - } | |
| 20 | - | |
| 21 | -} |
yudao-framework/yudao-spring-boot-starter-biz-mail/src/main/java/cn/iocoder/yudao/framework/mail/core/client/MailClient.java deleted
| 1 | -package cn.iocoder.yudao.framework.mail.core.client; | |
| 2 | - | |
| 3 | -import java.util.List; | |
| 4 | - | |
| 5 | -/** | |
| 6 | - * 邮件客户端,用于对接各邮箱平台的 SDK,实现邮件发送等功能 | |
| 7 | - * | |
| 8 | - * @author wangjingyi | |
| 9 | - * @date 2021/4/19 19:21 | |
| 10 | - */ | |
| 11 | -public interface MailClient { | |
| 12 | - | |
| 13 | - /** | |
| 14 | - * 发送邮件 | |
| 15 | - * | |
| 16 | - * @param from 邮箱账号 | |
| 17 | - * @param content 内容 | |
| 18 | - * @param title 标题 | |
| 19 | - * @param tos 收件人 | |
| 20 | - * @return 邮件发送结果 | |
| 21 | - */ | |
| 22 | - String sendMail(String from, String content, String title, List<String> tos); | |
| 23 | -} |
yudao-framework/yudao-spring-boot-starter-biz-mail/src/main/java/cn/iocoder/yudao/framework/mail/core/client/MailClientFactory.java deleted
yudao-framework/yudao-spring-boot-starter-biz-mail/src/main/java/cn/iocoder/yudao/framework/mail/core/client/MailCodeMapping.java deleted
| 1 | -package cn.iocoder.yudao.framework.mail.core.client; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.exception.ErrorCode; | |
| 4 | -import cn.iocoder.yudao.framework.mail.core.enums.MailFrameworkErrorCodeConstants; | |
| 5 | - | |
| 6 | -import java.util.function.Function; | |
| 7 | - | |
| 8 | -/** | |
| 9 | - * 将 API 的错误码,转换为通用的错误码 | |
| 10 | - * | |
| 11 | - * @see MailCommonResult | |
| 12 | - * @see MailFrameworkErrorCodeConstants | |
| 13 | - * | |
| 14 | - * @author 芋道源码 | |
| 15 | - */ | |
| 16 | -public interface MailCodeMapping extends Function<String, ErrorCode> { | |
| 17 | -} |
yudao-framework/yudao-spring-boot-starter-biz-mail/src/main/java/cn/iocoder/yudao/framework/mail/core/client/MailCommonResult.java deleted
| 1 | -package cn.iocoder.yudao.framework.mail.core.client; | |
| 2 | - | |
| 3 | -import cn.hutool.core.exceptions.ExceptionUtil; | |
| 4 | -import cn.hutool.core.lang.Assert; | |
| 5 | -import cn.iocoder.yudao.framework.common.exception.ErrorCode; | |
| 6 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 7 | -import lombok.Data; | |
| 8 | -import lombok.EqualsAndHashCode; | |
| 9 | -import lombok.ToString; | |
| 10 | -import cn.iocoder.yudao.framework.mail.core.enums.MailFrameworkErrorCodeConstants; | |
| 11 | - | |
| 12 | -/** | |
| 13 | - * 短信的 CommonResult 拓展类 | |
| 14 | - * | |
| 15 | - * 考虑到不同的平台,返回的 code 和 msg 是不同的,所以统一额外返回 {@link #apiCode} 和 {@link #apiMsg} 字段 | |
| 16 | - * | |
| 17 | - * 另外,一些短信平台(例如说阿里云、腾讯云)会返回一个请求编号,用于排查请求失败的问题,我们设置到 {@link #apiRequestId} 字段 | |
| 18 | - * | |
| 19 | - * @author 芋道源码 | |
| 20 | - */ | |
| 21 | -@Data | |
| 22 | -@EqualsAndHashCode(callSuper = true) | |
| 23 | -@ToString(callSuper = true) | |
| 24 | -public class MailCommonResult<T> extends CommonResult<T> { | |
| 25 | - | |
| 26 | - /** | |
| 27 | - * API 返回错误码 | |
| 28 | - * | |
| 29 | - * 由于第三方的错误码可能是字符串,所以使用 String 类型 | |
| 30 | - */ | |
| 31 | - private String apiCode; | |
| 32 | - /** | |
| 33 | - * API 返回提示 | |
| 34 | - */ | |
| 35 | - private String apiMsg; | |
| 36 | - | |
| 37 | - /** | |
| 38 | - * API 请求编号 | |
| 39 | - */ | |
| 40 | - private String apiRequestId; | |
| 41 | - | |
| 42 | - private MailCommonResult() { | |
| 43 | - } | |
| 44 | - | |
| 45 | - public static <T> MailCommonResult<T> build(String apiCode, String apiMsg, String apiRequestId, | |
| 46 | - T data, MailCodeMapping codeMapping) { | |
| 47 | - Assert.notNull(codeMapping, "参数 codeMapping 不能为空"); | |
| 48 | - MailCommonResult<T> result = new MailCommonResult<T>().setApiCode(apiCode).setApiMsg(apiMsg).setApiRequestId(apiRequestId); | |
| 49 | - result.setData(data); | |
| 50 | - // 翻译错误码 | |
| 51 | - if (codeMapping != null) { | |
| 52 | - ErrorCode errorCode = codeMapping.apply(apiCode); | |
| 53 | - if (errorCode == null) { | |
| 54 | - errorCode = MailFrameworkErrorCodeConstants.MAIL_UNKNOWN; | |
| 55 | - } | |
| 56 | - result.setCode(errorCode.getCode()).setMsg(errorCode.getMsg()); | |
| 57 | - } | |
| 58 | - return result; | |
| 59 | - } | |
| 60 | - | |
| 61 | - public static <T> MailCommonResult<T> error(Throwable ex) { | |
| 62 | - MailCommonResult<T> result = new MailCommonResult<>(); | |
| 63 | - result.setCode(MailFrameworkErrorCodeConstants.EXCEPTION.getCode()); | |
| 64 | - result.setMsg(ExceptionUtil.getRootCauseMessage(ex)); | |
| 65 | - return result; | |
| 66 | - } | |
| 67 | - | |
| 68 | -} |
yudao-framework/yudao-spring-boot-starter-biz-mail/src/main/java/cn/iocoder/yudao/framework/mail/core/client/dto/MailReceiveRespDTO.java deleted
| 1 | -package cn.iocoder.yudao.framework.mail.core.client.dto; | |
| 2 | - | |
| 3 | -import lombok.Data; | |
| 4 | - | |
| 5 | -import java.util.Date; | |
| 6 | - | |
| 7 | -/** | |
| 8 | - * 消息接收 Response DTO | |
| 9 | - * | |
| 10 | - * @author 芋道源码 | |
| 11 | - */ | |
| 12 | -@Data | |
| 13 | -public class MailReceiveRespDTO { | |
| 14 | - | |
| 15 | - /** | |
| 16 | - * 是否接收成功 | |
| 17 | - */ | |
| 18 | - private Boolean success; | |
| 19 | - /** | |
| 20 | - * API 接收结果的编码 | |
| 21 | - */ | |
| 22 | - private String errorCode; | |
| 23 | - /** | |
| 24 | - * API 接收结果的说明 | |
| 25 | - */ | |
| 26 | - private String errorMsg; | |
| 27 | - | |
| 28 | - /** | |
| 29 | - * 手机号 | |
| 30 | - */ | |
| 31 | - private String mobile; | |
| 32 | - /** | |
| 33 | - * 用户接收时间 | |
| 34 | - */ | |
| 35 | - private Date receiveTime; | |
| 36 | - | |
| 37 | - /** | |
| 38 | - * 短信 API 发送返回的序号 | |
| 39 | - */ | |
| 40 | - private String serialNo; | |
| 41 | - /** | |
| 42 | - * 短信日志编号 | |
| 43 | - * | |
| 44 | - * 对应 SysSmsLogDO 的编号 | |
| 45 | - */ | |
| 46 | - private Long logId; | |
| 47 | - | |
| 48 | -} |
yudao-framework/yudao-spring-boot-starter-biz-mail/src/main/java/cn/iocoder/yudao/framework/mail/core/client/dto/MailSendRespDTO.java deleted
yudao-framework/yudao-spring-boot-starter-biz-mail/src/main/java/cn/iocoder/yudao/framework/mail/core/client/dto/MailTemplateRespDTO.java deleted
| 1 | -package cn.iocoder.yudao.framework.mail.core.client.dto; | |
| 2 | - | |
| 3 | -import lombok.Data; | |
| 4 | - | |
| 5 | -/** | |
| 6 | - * 短信模板 Response DTO | |
| 7 | - * | |
| 8 | - * @author 芋道源码 | |
| 9 | - */ | |
| 10 | -@Data | |
| 11 | -public class MailTemplateRespDTO { | |
| 12 | - | |
| 13 | - /** | |
| 14 | - * 模板编号 | |
| 15 | - */ | |
| 16 | - private String id; | |
| 17 | - /** | |
| 18 | - * 短信内容 | |
| 19 | - */ | |
| 20 | - private String content; | |
| 21 | - /** | |
| 22 | - * 审核状态 | |
| 23 | - * | |
| 24 | - */ | |
| 25 | - private Integer auditStatus; | |
| 26 | - /** | |
| 27 | - * 审核未通过的理由 | |
| 28 | - */ | |
| 29 | - private String auditReason; | |
| 30 | - | |
| 31 | -} |
yudao-framework/yudao-spring-boot-starter-biz-mail/src/main/java/cn/iocoder/yudao/framework/mail/core/client/impl/AbstractMailClient.java deleted
| 1 | -package cn.iocoder.yudao.framework.mail.core.client.impl; | |
| 2 | - | |
| 3 | -import lombok.extern.slf4j.Slf4j; | |
| 4 | -import cn.iocoder.yudao.framework.mail.core.client.MailClient; | |
| 5 | - | |
| 6 | -/** | |
| 7 | - * 短信客户端的抽象类,提供模板方法,减少子类的冗余代码 | |
| 8 | - * | |
| 9 | - * @author zzf | |
| 10 | - * @date 2021/2/1 9:28 | |
| 11 | - */ | |
| 12 | -@Slf4j | |
| 13 | -public abstract class AbstractMailClient implements MailClient { | |
| 14 | -} |
yudao-framework/yudao-spring-boot-starter-biz-mail/src/main/java/cn/iocoder/yudao/framework/mail/core/client/impl/MailClientFactoryImpl.java deleted
| 1 | -package cn.iocoder.yudao.framework.mail.core.client.impl; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.mail.core.client.MailClient; | |
| 4 | -import cn.iocoder.yudao.framework.mail.core.client.impl.hutool.HutoolMailClient; | |
| 5 | -import lombok.extern.slf4j.Slf4j; | |
| 6 | -import cn.iocoder.yudao.framework.mail.core.client.MailClientFactory; | |
| 7 | -import cn.iocoder.yudao.framework.mail.core.enums.MailChannelEnum; | |
| 8 | -import org.springframework.validation.annotation.Validated; | |
| 9 | - | |
| 10 | -import java.util.Arrays; | |
| 11 | -import java.util.concurrent.ConcurrentHashMap; | |
| 12 | -import java.util.concurrent.ConcurrentMap; | |
| 13 | -@Validated | |
| 14 | -@Slf4j | |
| 15 | -public class MailClientFactoryImpl implements MailClientFactory { | |
| 16 | - | |
| 17 | - private final ConcurrentMap<String, AbstractMailClient> channelCodeClients = new ConcurrentHashMap<>(); | |
| 18 | - | |
| 19 | - public MailClientFactoryImpl (){ | |
| 20 | - Arrays.stream(MailChannelEnum.values()).forEach(mailChannelEnum -> { | |
| 21 | - AbstractMailClient abstractMailClient = createMailClient(mailChannelEnum); | |
| 22 | - channelCodeClients.put(mailChannelEnum.getCode() , abstractMailClient); | |
| 23 | - }); | |
| 24 | - } | |
| 25 | - | |
| 26 | - private AbstractMailClient createMailClient(MailChannelEnum mailChannelEnum) { | |
| 27 | - switch (mailChannelEnum){ | |
| 28 | - case HUTOOL: return new HutoolMailClient(); | |
| 29 | - } | |
| 30 | - // 创建失败,错误日志 + 抛出异常 | |
| 31 | - log.error("[createMailClient][配置({}) 找不到合适的客户端实现]" , mailChannelEnum); | |
| 32 | - throw new IllegalArgumentException(String.format("配置(%s) 找不到合适的客户端实现", mailChannelEnum)); | |
| 33 | - } | |
| 34 | - | |
| 35 | - @Override | |
| 36 | - public MailClient getMailClient() { | |
| 37 | - return channelCodeClients.get("HUTOOL"); | |
| 38 | - } | |
| 39 | -} |
yudao-framework/yudao-spring-boot-starter-biz-mail/src/main/java/cn/iocoder/yudao/framework/mail/core/client/impl/hutool/HutoolMailClient.java deleted
| 1 | -package cn.iocoder.yudao.framework.mail.core.client.impl.hutool; | |
| 2 | - | |
| 3 | -import cn.hutool.extra.mail.MailUtil; | |
| 4 | -import cn.iocoder.yudao.framework.mail.core.client.impl.AbstractMailClient; | |
| 5 | -import lombok.extern.slf4j.Slf4j; | |
| 6 | - | |
| 7 | -import java.util.List; | |
| 8 | - | |
| 9 | - | |
| 10 | -/** | |
| 11 | - * 邮件客户端实现 | |
| 12 | - * | |
| 13 | - * @author wangjingyi | |
| 14 | - * @date 2021/4/25 14:25 | |
| 15 | - */ | |
| 16 | -@Slf4j | |
| 17 | -public class HutoolMailClient extends AbstractMailClient { | |
| 18 | - | |
| 19 | - @Override | |
| 20 | - public String sendMail(String from, String content, String title, List<String> tos) { | |
| 21 | - try{ | |
| 22 | - return MailUtil.send(from , title , content , false , null); | |
| 23 | - }catch (Exception e){ | |
| 24 | - log.error(e.getMessage()); | |
| 25 | - } | |
| 26 | - return ""; | |
| 27 | - } | |
| 28 | - | |
| 29 | -} |
yudao-framework/yudao-spring-boot-starter-biz-mail/src/main/java/cn/iocoder/yudao/framework/mail/core/client/impl/hutool/HutoolMailCodeMapping.java deleted
| 1 | -package cn.iocoder.yudao.framework.mail.core.client.impl.hutool; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.exception.ErrorCode; | |
| 4 | -import cn.iocoder.yudao.framework.mail.core.client.MailCodeMapping; | |
| 5 | - | |
| 6 | -/** | |
| 7 | - * 阿里云的 SmsCodeMapping 实现类 | |
| 8 | - * | |
| 9 | - * 参见 https://help.aliyun.com/document_detail/101346.htm 文档 | |
| 10 | - * | |
| 11 | - * @author 芋道源码 | |
| 12 | - */ | |
| 13 | -public class HutoolMailCodeMapping implements MailCodeMapping { | |
| 14 | - | |
| 15 | - @Override | |
| 16 | - public ErrorCode apply(String apiCode) { | |
| 17 | - return null; | |
| 18 | - } | |
| 19 | - | |
| 20 | -} |
yudao-framework/yudao-spring-boot-starter-biz-mail/src/main/java/cn/iocoder/yudao/framework/mail/core/enums/MailChannelEnum.java deleted
| 1 | -package cn.iocoder.yudao.framework.mail.core.enums; | |
| 2 | - | |
| 3 | -import cn.hutool.core.util.ArrayUtil; | |
| 4 | -import lombok.AllArgsConstructor; | |
| 5 | -import lombok.Getter; | |
| 6 | - | |
| 7 | -/** | |
| 8 | - * 短信渠道枚举 | |
| 9 | - * | |
| 10 | - * @author zzf | |
| 11 | - * @date 2021/1/25 10:56 | |
| 12 | - */ | |
| 13 | -@Getter | |
| 14 | -@AllArgsConstructor | |
| 15 | -public enum MailChannelEnum { | |
| 16 | - HUTOOL("HUTOOL" , "HUTOOL"), | |
| 17 | - ; | |
| 18 | - | |
| 19 | - /** | |
| 20 | - * 编码 | |
| 21 | - */ | |
| 22 | - private final String code; | |
| 23 | - /** | |
| 24 | - * 名字 | |
| 25 | - */ | |
| 26 | - private final String name; | |
| 27 | - | |
| 28 | - public static MailChannelEnum getByCode(String code) { | |
| 29 | - return ArrayUtil.firstMatch(o -> o.getCode().equals(code), values()); | |
| 30 | - } | |
| 31 | - | |
| 32 | -} |
yudao-framework/yudao-spring-boot-starter-biz-mail/src/main/java/cn/iocoder/yudao/framework/mail/core/enums/MailFrameworkErrorCodeConstants.java deleted
| 1 | -package cn.iocoder.yudao.framework.mail.core.enums; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.exception.ErrorCode; | |
| 4 | - | |
| 5 | -/** | |
| 6 | - * 短信框架的错误码枚举 | |
| 7 | - * | |
| 8 | - * 短信框架,使用 2-001-000-000 段 | |
| 9 | - * | |
| 10 | - * @author 芋道源码 | |
| 11 | - */ | |
| 12 | -public interface MailFrameworkErrorCodeConstants { | |
| 13 | - | |
| 14 | - ErrorCode MAIL_UNKNOWN = new ErrorCode(2001000000, "未知错误,需要解析"); | |
| 15 | - | |
| 16 | - // ========== 权限 / 限流等相关 2001000100 ========== | |
| 17 | - | |
| 18 | - ErrorCode SMS_PERMISSION_DENY = new ErrorCode(2001000100, "没有发送短信的权限"); | |
| 19 | - // 云片:可以配置 IP 白名单,只有在白名单中才可以发送短信 | |
| 20 | - ErrorCode SMS_IP_DENY = new ErrorCode(2001000100, "IP 不允许发送短信"); | |
| 21 | - | |
| 22 | - // 阿里云:将短信发送频率限制在正常的业务限流范围内。默认短信验证码:使用同一签名,对同一个手机号验证码,支持 1 条 / 分钟,5 条 / 小时,累计 10 条 / 天。 | |
| 23 | - ErrorCode SMS_SEND_BUSINESS_LIMIT_CONTROL = new ErrorCode(2001000102, "指定手机的发送限流"); | |
| 24 | - // 阿里云:已经达到您在控制台设置的短信日发送量限额值。在国内消息设置 > 安全设置,修改发送总量阈值。 | |
| 25 | - ErrorCode SMS_SEND_DAY_LIMIT_CONTROL = new ErrorCode(2001000103, "每天的发送限流"); | |
| 26 | - | |
| 27 | - ErrorCode SMS_SEND_CONTENT_INVALID = new ErrorCode(2001000104, "短信内容有敏感词"); | |
| 28 | - | |
| 29 | - // ========== 模板相关 2001000200 ========== | |
| 30 | - ErrorCode SMS_TEMPLATE_INVALID = new ErrorCode(2001000200, "短信模板不合法"); // 包括短信模板不存在 | |
| 31 | - ErrorCode SMS_TEMPLATE_PARAM_ERROR = new ErrorCode(2001000201, "模板参数不正确"); | |
| 32 | - | |
| 33 | - // ========== 签名相关 2001000300 ========== | |
| 34 | - ErrorCode SMS_SIGN_INVALID = new ErrorCode(2001000300, "短信签名不可用"); | |
| 35 | - | |
| 36 | - // ========== 账户相关 2001000400 ========== | |
| 37 | - ErrorCode SMS_ACCOUNT_MONEY_NOT_ENOUGH = new ErrorCode(2001000400, "账户余额不足"); | |
| 38 | - ErrorCode SMS_ACCOUNT_INVALID = new ErrorCode(2001000401, "apiKey 不存在"); | |
| 39 | - | |
| 40 | - // ========== 其它相关 2001000900 开头 ========== | |
| 41 | - ErrorCode SMS_API_PARAM_ERROR = new ErrorCode(2001000900, "请求参数缺失"); | |
| 42 | - ErrorCode SMS_MOBILE_INVALID = new ErrorCode(2001000901, "手机格式不正确"); | |
| 43 | - ErrorCode SMS_MOBILE_BLACK = new ErrorCode(2001000902, "手机号在黑名单中"); | |
| 44 | - | |
| 45 | - ErrorCode EXCEPTION = new ErrorCode(2001000999, "调用异常"); | |
| 46 | - | |
| 47 | -} |
yudao-framework/yudao-spring-boot-starter-biz-mail/src/main/java/cn/iocoder/yudao/framework/mail/core/enums/MailTemplateAuditStatusEnum.java deleted
| 1 | -package cn.iocoder.yudao.framework.mail.core.enums; | |
| 2 | - | |
| 3 | -import lombok.AllArgsConstructor; | |
| 4 | -import lombok.Getter; | |
| 5 | - | |
| 6 | -/** | |
| 7 | - * 短信模板的审核状态枚举 | |
| 8 | - * | |
| 9 | - * @author 芋道源码 | |
| 10 | - */ | |
| 11 | -@AllArgsConstructor | |
| 12 | -@Getter | |
| 13 | -public enum MailTemplateAuditStatusEnum { | |
| 14 | - | |
| 15 | - CHECKING(1), | |
| 16 | - SUCCESS(2), | |
| 17 | - FAIL(3); | |
| 18 | - | |
| 19 | - private final Integer status; | |
| 20 | - | |
| 21 | -} |
yudao-framework/yudao-spring-boot-starter-biz-mail/src/main/java/cn/iocoder/yudao/framework/mail/core/property/MailChannelProperties.java deleted
| 1 | -package cn.iocoder.yudao.framework.mail.core.property; | |
| 2 | - | |
| 3 | -import lombok.Data; | |
| 4 | -import cn.iocoder.yudao.framework.mail.core.enums.MailChannelEnum; | |
| 5 | -import org.springframework.validation.annotation.Validated; | |
| 6 | - | |
| 7 | -import javax.validation.constraints.NotEmpty; | |
| 8 | -import javax.validation.constraints.NotNull; | |
| 9 | - | |
| 10 | -/** | |
| 11 | - * 短信渠道配置类 | |
| 12 | - * | |
| 13 | - * @author zzf | |
| 14 | - * @date 2021/1/25 17:01 | |
| 15 | - */ | |
| 16 | -@Data | |
| 17 | -@Validated | |
| 18 | -public class MailChannelProperties { | |
| 19 | - | |
| 20 | - /** | |
| 21 | - * 渠道编号 | |
| 22 | - */ | |
| 23 | - @NotNull(message = "短信渠道 ID 不能为空") | |
| 24 | - private Long id; | |
| 25 | - /** | |
| 26 | - * 短信签名 | |
| 27 | - */ | |
| 28 | - @NotEmpty(message = "短信签名不能为空") | |
| 29 | - private String signature; | |
| 30 | - /** | |
| 31 | - * 渠道编码 | |
| 32 | - * | |
| 33 | - * 枚举 {@link MailChannelEnum} | |
| 34 | - */ | |
| 35 | - @NotEmpty(message = "渠道编码不能为空") | |
| 36 | - private String code; | |
| 37 | - /** | |
| 38 | - * 短信 API 的账号 | |
| 39 | - */ | |
| 40 | - @NotEmpty(message = "短信 API 的账号不能为空") | |
| 41 | - private String apiKey; | |
| 42 | - /** | |
| 43 | - * 短信 API 的秘钥 | |
| 44 | - */ | |
| 45 | - @NotEmpty(message = "短信 API 的秘钥不能为空") | |
| 46 | - private String apiSecret; | |
| 47 | - /** | |
| 48 | - * 短信发送回调 URL | |
| 49 | - */ | |
| 50 | - private String callbackUrl; | |
| 51 | - | |
| 52 | -} |
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
| ... | ... | @@ -119,13 +119,17 @@ public interface ErrorCodeConstants { |
| 119 | 119 | ErrorCode SOCIAL_USER_UNBIND_NOT_SELF = new ErrorCode(1002018001, "社交解绑失败,非当前用户绑定"); |
| 120 | 120 | ErrorCode SOCIAL_USER_NOT_FOUND = new ErrorCode(1002018002, "社交授权失败,找不到对应的用户"); |
| 121 | 121 | |
| 122 | - // ========== 邮箱账号 1002019000 ========== | |
| 123 | - ErrorCode MAIL_ACCOUNT_NOT_EXISTS = new ErrorCode(1002019000, "邮箱账号不存在"); | |
| 124 | - ErrorCode MAIL_ACCOUNT_EXISTS = new ErrorCode(1002019001, "邮箱账号存在"); | |
| 125 | - | |
| 126 | - // ========== 邮箱模版 1002020000 ========== | |
| 127 | - ErrorCode MAIL_TEMPLATE_NOT_EXISTS = new ErrorCode(1002020000 , "邮箱模版不存在"); | |
| 128 | - ErrorCode MAIL_TEMPLATE_EXISTS = new ErrorCode(1002020001, "邮箱模版存在"); | |
| 129 | - ErrorCode MAIL_RELATE_TEMPLATE_EXISTS = new ErrorCode(1002020002, "存在关联邮箱模版"); | |
| 122 | + // ========== 系统铭感词 1002019000 ========= | |
| 123 | + ErrorCode SENSITIVE_WORD_NOT_EXISTS = new ErrorCode(1002019000, "系统敏感词在所有标签中都不存在"); | |
| 124 | + ErrorCode SENSITIVE_WORD_EXISTS = new ErrorCode(1002019001, "系统敏感词已在标签中存在"); | |
| 125 | + | |
| 126 | + // ========== 邮箱账号 1002020000 ========== | |
| 127 | + ErrorCode MAIL_ACCOUNT_NOT_EXISTS = new ErrorCode(1002020000, "邮箱账号不存在"); | |
| 128 | + ErrorCode MAIL_ACCOUNT_EXISTS = new ErrorCode(1002020001, "邮箱账号存在"); | |
| 129 | + | |
| 130 | + // ========== 邮箱模版 1002021000 ========== | |
| 131 | + ErrorCode MAIL_TEMPLATE_NOT_EXISTS = new ErrorCode(1002021000 , "邮箱模版不存在"); | |
| 132 | + ErrorCode MAIL_TEMPLATE_EXISTS = new ErrorCode(1002021001, "邮箱模版存在"); | |
| 133 | + ErrorCode MAIL_RELATE_TEMPLATE_EXISTS = new ErrorCode(1002021002, "存在关联邮箱模版"); | |
| 130 | 134 | |
| 131 | 135 | } | ... | ... |
yudao-module-system/yudao-module-system-biz/pom.xml
| ... | ... | @@ -44,10 +44,6 @@ |
| 44 | 44 | </dependency> |
| 45 | 45 | <dependency> |
| 46 | 46 | <groupId>cn.iocoder.boot</groupId> |
| 47 | - <artifactId>yudao-spring-boot-starter-biz-mail</artifactId> | |
| 48 | - </dependency> | |
| 49 | - <dependency> | |
| 50 | - <groupId>cn.iocoder.boot</groupId> | |
| 51 | 47 | <artifactId>yudao-spring-boot-starter-biz-data-permission</artifactId> |
| 52 | 48 | </dependency> |
| 53 | 49 | <dependency> | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/mail/MailTemplateConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.system.convert.mail; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountBaseVO; | |
| 5 | 4 | import cn.iocoder.yudao.module.system.controller.admin.mail.vo.template.MailTemplateBaseVO; |
| 6 | -import cn.iocoder.yudao.module.system.controller.admin.mail.vo.template.MailTemplateCreateReqVO; | |
| 7 | -import cn.iocoder.yudao.module.system.convert.errorcode.ErrorCodeConvertImpl; | |
| 8 | -import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO; | |
| 9 | 5 | import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO; |
| 10 | 6 | import org.mapstruct.Mapper; |
| 11 | 7 | import org.mapstruct.factory.Mappers; | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/mail/impl/MailSendServiceImpl.java
| ... | ... | @@ -13,10 +13,8 @@ import cn.iocoder.yudao.module.system.service.mail.MailLogService; |
| 13 | 13 | import cn.iocoder.yudao.module.system.service.mail.MailSendService; |
| 14 | 14 | import cn.iocoder.yudao.module.system.service.mail.MailTemplateService; |
| 15 | 15 | import lombok.extern.slf4j.Slf4j; |
| 16 | -import cn.iocoder.yudao.framework.mail.core.client.MailClientFactory; | |
| 17 | 16 | import org.springframework.stereotype.Service; |
| 18 | 17 | import org.springframework.validation.annotation.Validated; |
| 19 | -import cn.iocoder.yudao.framework.mail.core.client.MailClient; | |
| 20 | 18 | |
| 21 | 19 | import javax.annotation.Resource; |
| 22 | 20 | import java.util.List; |
| ... | ... | @@ -46,8 +44,6 @@ public class MailSendServiceImpl implements MailSendService { |
| 46 | 44 | @Resource |
| 47 | 45 | private MailLogService mailLogService; |
| 48 | 46 | @Resource |
| 49 | - private MailClientFactory mailClientFactory; | |
| 50 | - @Resource | |
| 51 | 47 | private MailProducer mailProducer; |
| 52 | 48 | |
| 53 | 49 | |
| ... | ... | @@ -80,9 +76,9 @@ public class MailSendServiceImpl implements MailSendService { |
| 80 | 76 | @Override |
| 81 | 77 | public void doSendMail(MailSendMessage message) { |
| 82 | 78 | // TODO @wangjingyi:直接使用 hutool 发送,不要封装 mail client 哈,因为短信的客户端都是比较统一的 |
| 83 | - MailClient mailClient = mailClientFactory.getMailClient(); | |
| 84 | - String result = mailClient.sendMail(message.getFrom() , message.getContent() , message.getTitle() , message.getTos()); | |
| 85 | - mailLogService.updateSmsSendResult(message.getLogId() , result); | |
| 79 | + //MailClient mailClient = mailClientFactory.getMailClient(); | |
| 80 | + //String result = mailClient.sendMail(message.getFrom() , message.getContent() , message.getTitle() , message.getTos()); | |
| 81 | + //mailLogService.updateSmsSendResult(message.getLogId() , result); | |
| 86 | 82 | } |
| 87 | 83 | |
| 88 | 84 | private MailTemplateDO checkMailTemplateValid(String templateCode) { | ... | ... |