From 0723f5fc19d6e99b275953064b83f2fbe7e97452 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Thu, 9 Apr 2020 17:17:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B1=85=E6=B0=91=E6=B3=A8=E5=86=8C=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=89=8B=E6=9C=BA=E9=AA=8C=E8=AF=81=E7=A0=81=E5=86=8D?= =?UTF-8?q?=E6=AC=A1=E8=8E=B7=E5=8F=96=E6=97=B6=E5=88=A0=E9=99=A4=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E4=B8=AD=E5=8F=AF=E8=83=BD=E5=AD=98=E5=9C=A8=E7=9A=84?= =?UTF-8?q?=E6=97=A7=E9=AA=8C=E8=AF=81=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/commons/tools/redis/RedisKeys.java | 13 +++++++++++++ .../java/com/epmet/redis/UserResiInfoRedis.java | 5 +++++ .../epmet/service/impl/UserResiInfoServiceImpl.java | 9 ++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java index 9e18f31ecd..b0deec2e02 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java @@ -161,4 +161,17 @@ public class RedisKeys { return rootPrefix.concat("resiregister:confirm:").concat(userId).concat("-").concat(mobile).concat("-").concat(code); } + /** + * + * 居民注册手机验证码key(模糊检索Key) + * + * @param userId 用户id + * @param mobile 手机号 + * @return String + * @author sun + */ + public static String getResiRegisterMobileCodeKey(String userId, String mobile) { + return rootPrefix.concat("resiregister:confirm:").concat(userId).concat("-").concat(mobile).concat("-*"); + } + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserResiInfoRedis.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserResiInfoRedis.java index 837d0cd229..1ce33a14da 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserResiInfoRedis.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserResiInfoRedis.java @@ -56,4 +56,9 @@ public class UserResiInfoRedis { return (String) redisUtils.get(key); } + public void deleteOldUserMobileCode(String userId, String mobile){ + String key = RedisKeys.getResiRegisterMobileCodeKey(userId, mobile); + redisUtils.deleteByPattern(key); + } + } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserResiInfoServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserResiInfoServiceImpl.java index 37912e61f4..3bab0b3fdf 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserResiInfoServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserResiInfoServiceImpl.java @@ -212,8 +212,15 @@ public class UserResiInfoServiceImpl extends BaseServiceImpl map = (Map) result.getData(); + if(null == map) { + result.setCode(EpmetErrorCode.MOBILE_GET_CODE_ERROR.getValue()); + result.setMsg(EpmetErrorCode.MOBILE_GET_CODE_ERROR.getName()); + return result; + } + //4:删除缓存中可能存在的旧验证码 + userResiInfoRedis.deleteOldUserMobileCode(verificationCodeFormDTO.getUserId(), verificationCodeFormDTO.getMobile()); + //5:将验证码存入redis userResiInfoRedis.setUserResiMobileCode(verificationCodeFormDTO.getUserId(),verificationCodeFormDTO.getMobile(),map.get("code").toString()); return result; }