|
@@ -2,11 +2,8 @@ package com.qmth.themis.business.util;
|
|
|
|
|
|
import com.qmth.themis.business.constant.SpringContextHolder;
|
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
|
-import com.qmth.themis.common.enums.Platform;
|
|
|
-import com.qmth.themis.common.enums.Source;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
|
|
|
-import java.util.Objects;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
@@ -68,23 +65,7 @@ public class RedisUtil {
|
|
|
*/
|
|
|
public static void setUser(Long userId, Object o) {
|
|
|
RedisTemplate redisTemplate = SpringContextHolder.getBean(RedisTemplate.class);
|
|
|
- redisTemplate.opsForValue().set(SystemConstant.USER + userId, o, SystemConstant.JWT_WEB_EXPIRE_TIME, TimeUnit.SECONDS);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 设置用户信息
|
|
|
- *
|
|
|
- * @param userId
|
|
|
- * @param platform
|
|
|
- * @param o
|
|
|
- */
|
|
|
- public static void setUser(Long userId, Platform platform, Object o) {
|
|
|
- RedisTemplate redisTemplate = SpringContextHolder.getBean(RedisTemplate.class);
|
|
|
- if (Objects.equals(platform.getSource(), Source.Phone.name())) {
|
|
|
- redisTemplate.opsForValue().set(SystemConstant.USER + userId, o, SystemConstant.JWT_PAD_EXPIRE_TIME, TimeUnit.SECONDS);
|
|
|
- } else {
|
|
|
- redisTemplate.opsForValue().set(SystemConstant.USER + userId, o, SystemConstant.expireTime(platform), TimeUnit.SECONDS);
|
|
|
- }
|
|
|
+ redisTemplate.opsForValue().set(SystemConstant.USER + userId, o, SystemConstant.REDIS_EXPIRE_TIME, TimeUnit.SECONDS);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -94,22 +75,7 @@ public class RedisUtil {
|
|
|
*/
|
|
|
public static void refreshUser(Long userId) {
|
|
|
RedisTemplate redisTemplate = SpringContextHolder.getBean(RedisTemplate.class);
|
|
|
- redisTemplate.expire(SystemConstant.USER + userId, SystemConstant.JWT_WEB_EXPIRE_TIME, TimeUnit.SECONDS);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 刷新用户缓存
|
|
|
- *
|
|
|
- * @param userId
|
|
|
- * @param platform
|
|
|
- */
|
|
|
- public static void refreshUser(Long userId, Platform platform) {
|
|
|
- RedisTemplate redisTemplate = SpringContextHolder.getBean(RedisTemplate.class);
|
|
|
- if (Objects.equals(platform.getSource(), Source.Phone.name())) {
|
|
|
- redisTemplate.expire(SystemConstant.USER + userId, SystemConstant.JWT_PAD_EXPIRE_TIME, TimeUnit.SECONDS);
|
|
|
- } else {
|
|
|
- redisTemplate.expire(SystemConstant.USER + userId, SystemConstant.expireTime(platform), TimeUnit.SECONDS);
|
|
|
- }
|
|
|
+ redisTemplate.expire(SystemConstant.USER + userId, SystemConstant.REDIS_REFRESH_EXPIRE_TIME, TimeUnit.SECONDS);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -127,31 +93,21 @@ public class RedisUtil {
|
|
|
* 设置用户session信息
|
|
|
*
|
|
|
* @param sessionId
|
|
|
- * @param platform
|
|
|
* @param o
|
|
|
*/
|
|
|
- public static void setUserSession(String sessionId, Platform platform, Object o) {
|
|
|
+ public static void setUserSession(String sessionId, Object o) {
|
|
|
RedisTemplate redisTemplate = SpringContextHolder.getBean(RedisTemplate.class);
|
|
|
- if (Objects.equals(platform.getSource(), Source.Phone.name())) {
|
|
|
- redisTemplate.opsForValue().set(SystemConstant.SESSION + sessionId, o, SystemConstant.JWT_PAD_EXPIRE_TIME, TimeUnit.SECONDS);
|
|
|
- } else {
|
|
|
- redisTemplate.opsForValue().set(SystemConstant.SESSION + sessionId, o, SystemConstant.expireTime(platform), TimeUnit.SECONDS);
|
|
|
- }
|
|
|
+ redisTemplate.opsForValue().set(SystemConstant.SESSION + sessionId, o, SystemConstant.REDIS_EXPIRE_TIME, TimeUnit.SECONDS);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 刷新用户session缓存
|
|
|
*
|
|
|
* @param sessionId
|
|
|
- * @param platform
|
|
|
*/
|
|
|
- public static void refreshUserSession(String sessionId, Platform platform) {
|
|
|
+ public static void refreshUserSession(String sessionId) {
|
|
|
RedisTemplate redisTemplate = SpringContextHolder.getBean(RedisTemplate.class);
|
|
|
- if (Objects.equals(platform.getSource(), Source.Phone.name())) {
|
|
|
- redisTemplate.expire(SystemConstant.SESSION + sessionId, SystemConstant.JWT_PAD_EXPIRE_TIME, TimeUnit.SECONDS);
|
|
|
- } else {
|
|
|
- redisTemplate.expire(SystemConstant.SESSION + sessionId, SystemConstant.expireTime(platform), TimeUnit.SECONDS);
|
|
|
- }
|
|
|
+ redisTemplate.expire(SystemConstant.SESSION + sessionId, SystemConstant.REDIS_REFRESH_EXPIRE_TIME, TimeUnit.SECONDS);
|
|
|
}
|
|
|
|
|
|
/**
|