|
@@ -5,14 +5,12 @@ import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Random;
|
|
|
|
|
|
-import com.ym.mec.common.redis.service.RedisCache;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
-import org.springframework.data.redis.core.ValueOperations;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -26,9 +24,9 @@ import com.ym.mec.biz.dal.enums.SendStatusEnum;
|
|
|
import com.ym.mec.biz.dal.enums.SendTypeEnum;
|
|
|
import com.ym.mec.biz.service.SysMessageConfigService;
|
|
|
import com.ym.mec.biz.service.SysMessageService;
|
|
|
-import com.ym.mec.common.cache.Cache;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
|
+import com.ym.mec.common.redis.service.RedisCache;
|
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
|
|
|
import com.ym.mec.thirdparty.message.MessageSenderPluginContext.MessageSender;
|
|
@@ -52,7 +50,9 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
|
|
|
private SysUserFeignService sysUserFeignService;
|
|
|
|
|
|
@Autowired
|
|
|
- private RedisTemplate redisTemplate;
|
|
|
+ private RedisTemplate<String,Object> redisTemplate;
|
|
|
+
|
|
|
+ private RedisCache<String,Object> redisCache = new RedisCache<String, Object>(redisTemplate);
|
|
|
|
|
|
// 验证码有效期
|
|
|
public static final int CODE_EXPIRE = 60 * 5;
|
|
@@ -219,7 +219,6 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
|
|
|
@Override
|
|
|
public boolean sendSecurityCode(MessageSender messageSender, Integer userId, SendTypeEnum mode, MessageType messageType, String receiver) {
|
|
|
String key1 = getVerificationCode1CacheKey(messageType, receiver);
|
|
|
- ValueOperations redisCache = redisTemplate.opsForValue();
|
|
|
if (redisCache.get(key1) != null) {
|
|
|
throw new BizException("请勿频繁操作,获取验证码间隔时间为60秒");
|
|
|
}
|
|
@@ -230,8 +229,8 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
|
|
|
code = getRandomCode(messageType, receiver);
|
|
|
}
|
|
|
sendMessage(messageSender, userId, mode, messageType, receiver, null, 1, "", code);
|
|
|
- redisCache.set(key, code, CODE_EXPIRE);
|
|
|
- redisCache.set(key1, code, CODE_INTERVAL_TIME);
|
|
|
+ redisCache.put(key, code, CODE_EXPIRE);
|
|
|
+ redisCache.put(key1, code, CODE_INTERVAL_TIME);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -241,7 +240,6 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
|
|
|
return DEFAULT_CODE + "";
|
|
|
}
|
|
|
String key = getVerificationCodeCacheKey(type, mobileNOOrEmailAddr);
|
|
|
- ValueOperations redisCache = redisTemplate.opsForValue();
|
|
|
Object object = redisCache.get(key);
|
|
|
return object == null ? null : object.toString();
|
|
|
}
|
|
@@ -250,7 +248,7 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
|
|
|
public void delSendedVerificationCode(MessageType type, String mobileNOOrEmailAddr) {
|
|
|
String key = getVerificationCodeCacheKey(type, mobileNOOrEmailAddr);
|
|
|
if (StringUtils.isNotBlank(key)) {
|
|
|
- redisTemplate.delete(key);
|
|
|
+ redisCache.delete(key);
|
|
|
}
|
|
|
}
|
|
|
|