From e14aeae38a92ddacb8b93ebb45f09d411f6bc2c6 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Thu, 5 Sep 2024 17:20:40 +0800 Subject: [PATCH] =?UTF-8?q?modify:=201.=20=E7=BB=88=E6=AD=A2=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E6=9B=BF=E6=8D=A2;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hz/pm/api/sms/manage/VerificationCodeManage.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/sms/manage/VerificationCodeManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/sms/manage/VerificationCodeManage.java index a2f3453..4a9e103 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/sms/manage/VerificationCodeManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/sms/manage/VerificationCodeManage.java @@ -2,8 +2,8 @@ package com.hz.pm.api.sms.manage; import cn.hutool.core.util.PhoneUtil; import cn.hutool.core.util.RandomUtil; +import com.hz.pm.api.common.exception.ReturnException; import com.hz.pm.api.common.helper.MsgCallHelper; -import com.hz.pm.api.external.sms.MhSmsClient; import com.hz.pm.api.sms.constant.VerificationCodeType; import com.hz.pm.api.sms.constant.VoiceSmsTemplateConst; import com.hz.pm.api.sms.model.dto.VerifyCodeCacheDTO; @@ -11,7 +11,6 @@ import com.hz.pm.api.sms.model.po.ReqVerificationCodePO; import com.hz.pm.api.sms.utils.DateUtil; import com.hz.pm.api.sms.utils.SmsRedisKeyUtils; import com.hz.pm.api.sys.model.enumeration.BizTypeEnum; -import com.ningdatech.basic.exception.BizException; import com.ningdatech.cache.model.cache.CacheKey; import com.ningdatech.cache.repository.CachePlusOps; import lombok.RequiredArgsConstructor; @@ -22,7 +21,6 @@ import org.springframework.util.Assert; import java.time.Duration; import java.time.LocalDateTime; -import java.util.Collections; import java.util.Objects; /** @@ -45,14 +43,14 @@ public class VerificationCodeManage { // 验证是否被锁定 String lockKey = SmsRedisKeyUtils.smsSendLockKey(codeType, req.getMobile()); if (StringUtils.isNotBlank(cachePlusOps.get(lockKey))) { - throw BizException.wrap("今日" + codeType.getDesc() + "的验证码发送次数过多,已被锁定"); + throw ReturnException.wrap("今日" + codeType.getDesc() + "的验证码发送次数过多,已被锁定"); } // 验证发送间隔 String cacheKey = SmsRedisKeyUtils.smsCodeVerifyKey(codeType, req.getMobile()); VerifyCodeCacheDTO preCache = cachePlusOps.get(cacheKey); if (preCache != null && (LocalDateTime.now().minusMinutes(codeType.getSendInterval()) .isBefore(preCache.getSendTime()))) { - throw BizException.wrap(codeType.getSendInterval() + "分钟之内已发送过验证码,请稍后重试"); + throw ReturnException.wrap(codeType.getSendInterval() + "分钟之内已发送过验证码,请稍后重试"); } String code = RandomUtil.randomNumbers(6); VerifyCodeCacheDTO cache = VerifyCodeCacheDTO.builder() @@ -74,7 +72,7 @@ public class VerificationCodeManage { } break; default: - throw new IllegalArgumentException("非法的短信发送类型"); + throw ReturnException.wrap("非法的短信发送类型"); } // 发送 短信