邮件-校验发送结果

This commit is contained in:
khalil
2025-07-09 14:34:14 +08:00
parent 854db8cc0d
commit d393ede84d
4 changed files with 18 additions and 3 deletions

View File

@@ -931,6 +931,7 @@ public enum BusiStatus {
PIC_UPLOAD_REVIEW_EXCEPTION(500, "PIC UPLOAD REVIEW EXCEPTION!"),
EMAIL_CODE_SEND_SUCCESS(200, "邮件验证码發送成功"),
EMAIL_CODE_SEND_FAILURE(200, "邮件验证码發送失败"),
EMAIL_FORMAT_ERROR(3011, "邮箱格式错误"),
ACCOUNT_NOT_BIND_EMAIL(3012, "帐号未绑定邮箱"),
ACCOUNT_BIND_EMAIL_DIFF(3013, "提交的邮箱不是当前帐号已绑定的邮箱"),

View File

@@ -10,6 +10,8 @@ import lombok.Data;
@Data
public class EmailResponse {
public final String SUCCESS_CODE = "200";
/**
* 异常编码
*/
@@ -19,4 +21,14 @@ public class EmailResponse {
* 异常信息
*/
private String message;
public boolean isSuccess() {
return SUCCESS_CODE.equals(code);
}
public void success() {
this.setCode(SUCCESS_CODE);
this.setMessage("OK");
}
}

View File

@@ -80,7 +80,10 @@ public class EmailService extends BaseService {
//新增短信记录
emailRecordService.saveRecord(emailAddress, deviceInfo, ip, code, type, response.getCode(), response.getMessage());
//todo 响应编码校验
if (!response.isSuccess()){
throw new ServiceException(BusiStatus.EMAIL_CODE_SEND_FAILURE);
}
// 写入短信发送频率
intervalBucket.set(StrUtil.EMPTY, EmailConstant.SEND_INTERVAL_SECONDS, TimeUnit.SECONDS);

View File

@@ -24,8 +24,7 @@ public class TencentEmailStrategy extends EmailStrategy{
try {
SendEmailResponse response = SpringContextHolder.getBean(TencentSecService.class).sendMailCode(context.getEmail(), context.getCode(), EmailConstant.EXPIRE_MINUTE);
r.setCode("200");
r.setMessage("OK");
r.success();
log.info("sendEmailCode success {}", JSON.toJSONString(response));