|
@@ -1,7 +1,7 @@
|
|
|
package com.hfln.portal.infrastructure.gateway.impl.sms;
|
|
|
|
|
|
-import cn.hfln.framework.common.redis.service.RedisService;
|
|
|
import cn.hfln.framework.extension.BizException;
|
|
|
+import cn.hfln.framework.redis.util.RedisUtil;
|
|
|
import com.hfln.portal.common.constant.redis.RedisCacheConstant;
|
|
|
import com.hfln.portal.domain.customer.util.MsgClient;
|
|
|
import com.hfln.portal.domain.exception.ErrorEnum;
|
|
@@ -22,7 +22,7 @@ public class SmsGatewayImpl implements SmsGateway {
|
|
|
private MsgClient msgClient;
|
|
|
|
|
|
@Autowired
|
|
|
- private RedisService redisService;
|
|
|
+ private RedisUtil redisService;
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -33,12 +33,12 @@ public class SmsGatewayImpl implements SmsGateway {
|
|
|
if (hasKey) {
|
|
|
throw new BizException(ErrorEnum.FREQUENT_SMS_SENDING.getErrorCode(), ErrorEnum.FREQUENT_SMS_SENDING.getErrorMessage());
|
|
|
}
|
|
|
- redisService.setCacheObject(key, 1, 1L, TimeUnit.MINUTES);
|
|
|
+ redisService.set(key, 1, 1L, TimeUnit.MINUTES);
|
|
|
int captcha = (int) ((Math.random() * 9 + 1) * 1000);
|
|
|
String sentLoginMsg = msgClient.sendLoginMsg(phone, String.valueOf(captcha));
|
|
|
if (Objects.nonNull(sentLoginMsg)) {
|
|
|
// 存入redis 过期时间十分钟
|
|
|
- redisService.setCacheObject(RedisCacheConstant.SMS_LOGIN_CODE + phone, captcha,10L, TimeUnit.MINUTES);
|
|
|
+ redisService.set(RedisCacheConstant.SMS_LOGIN_CODE + phone, captcha,10L, TimeUnit.MINUTES);
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
@@ -59,11 +59,11 @@ public class SmsGatewayImpl implements SmsGateway {
|
|
|
if (Objects.nonNull(sentLoginMsg)) {
|
|
|
// 存入redis 过期时间十分钟
|
|
|
String redisKey = RedisCacheConstant.SMS_SIGNUP_CODE + phone;
|
|
|
- redisService.setCacheObject(redisKey, captcha, 10L, TimeUnit.MINUTES);
|
|
|
+ redisService.set(redisKey, captcha, 10L, TimeUnit.MINUTES);
|
|
|
log.info("验证码已存入Redis:key={}, value={}, 过期时间=10分钟", redisKey, captcha);
|
|
|
|
|
|
// 验证是否存储成功
|
|
|
- Object storedValue = redisService.getCacheObject(redisKey);
|
|
|
+ Object storedValue = redisService.get(redisKey);
|
|
|
log.info("验证存储结果:key={}, 存储的值={}", redisKey, storedValue);
|
|
|
return true;
|
|
|
}
|
|
@@ -86,11 +86,11 @@ public class SmsGatewayImpl implements SmsGateway {
|
|
|
if (Objects.nonNull(sentLoginMsg)) {
|
|
|
// 存入redis 过期时间十分钟
|
|
|
String redisKey = RedisCacheConstant.SMS_RESET_CODE + phone;
|
|
|
- redisService.setCacheObject(redisKey, captcha, 10L, TimeUnit.MINUTES);
|
|
|
+ redisService.set(redisKey, captcha, 10L, TimeUnit.MINUTES);
|
|
|
log.info("验证码已存入Redis:key={}, value={}, 过期时间=10分钟", redisKey, captcha);
|
|
|
|
|
|
// 验证是否存储成功
|
|
|
- Object storedValue = redisService.getCacheObject(redisKey);
|
|
|
+ Object storedValue = redisService.get(redisKey);
|
|
|
log.info("验证存储结果:key={}, 存储的值={}", redisKey, storedValue);
|
|
|
return true;
|
|
|
}
|