From e7ae87a6f9224a43b994b5118247f9acbb85719b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E6=B2=90?= Date: Tue, 25 Jun 2024 17:23:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/net/maku/message/cache/SmsSendCache.java | 44 ---------------------- .../java/net/maku/system/cache/SmsSendCache.java | 44 ++++++++++++++++++++++ 2 files changed, 44 insertions(+), 44 deletions(-) delete mode 100644 maku-boot-module/maku-module-message/src/main/java/net/maku/message/cache/SmsSendCache.java create mode 100644 maku-boot-system/src/main/java/net/maku/system/cache/SmsSendCache.java diff --git a/maku-boot-module/maku-module-message/src/main/java/net/maku/message/cache/SmsSendCache.java b/maku-boot-module/maku-module-message/src/main/java/net/maku/message/cache/SmsSendCache.java deleted file mode 100644 index a873f4e..0000000 --- a/maku-boot-module/maku-module-message/src/main/java/net/maku/message/cache/SmsSendCache.java +++ /dev/null @@ -1,44 +0,0 @@ -package net.maku.message.cache; - -import lombok.AllArgsConstructor; -import net.maku.framework.common.cache.RedisCache; -import org.springframework.stereotype.Service; - -/** - * 短信发送 Cache - * - * @author 阿沐 babamu@126.com - * MAKU - */ -@Service -@AllArgsConstructor -public class SmsSendCache { - private final RedisCache redisCache; - - /** - * 获取发送手机短信验证码KEY - * - * @param mobile 手机号 - * @return KEY - */ - private String getCodeKey(String mobile) { - return "message:sms:code" + mobile; - } - - public void saveCode(String mobile, String code) { - String key = getCodeKey(mobile); - - // 保存到Redis,有效期10分钟 - redisCache.set(key, code, 10 * 60); - } - - public String getCode(String mobile) { - String key = getCodeKey(mobile); - return (String) redisCache.get(key); - } - - public void deleteCode(String mobile) { - String key = getCodeKey(mobile); - redisCache.delete(key); - } -} diff --git a/maku-boot-system/src/main/java/net/maku/system/cache/SmsSendCache.java b/maku-boot-system/src/main/java/net/maku/system/cache/SmsSendCache.java new file mode 100644 index 0000000..565e0d5 --- /dev/null +++ b/maku-boot-system/src/main/java/net/maku/system/cache/SmsSendCache.java @@ -0,0 +1,44 @@ +package net.maku.system.cache; + +import lombok.AllArgsConstructor; +import net.maku.framework.common.cache.RedisCache; +import org.springframework.stereotype.Service; + +/** + * 短信发送 Cache + * + * @author 阿沐 babamu@126.com + * MAKU + */ +@Service +@AllArgsConstructor +public class SmsSendCache { + private final RedisCache redisCache; + + /** + * 获取发送手机短信验证码KEY + * + * @param mobile 手机号 + * @return KEY + */ + private String getCodeKey(String mobile) { + return "sys:sms:code" + mobile; + } + + public void saveCode(String mobile, String code) { + String key = getCodeKey(mobile); + + // 保存到Redis,有效期10分钟 + redisCache.set(key, code, 10 * 60); + } + + public String getCode(String mobile) { + String key = getCodeKey(mobile); + return (String) redisCache.get(key); + } + + public void deleteCode(String mobile) { + String key = getCodeKey(mobile); + redisCache.delete(key); + } +}