Commit 191cb5e7 authored by xuepeng.chang's avatar xuepeng.chang

日志打印

parent 9a37979b
......@@ -531,6 +531,7 @@ public class UserController implements IBaseController {
} else {
tokenKey2 = Constants.Session.USER_SESSION_CACHE + tenantId + ":" + token;
}
log.info("获取token key,token:{},tokenKey:{}", token, tokenKey2);
// 判断token是否存在
boolean exist = stringRedisTemplate.hasKey(tokenKey) || stringRedisTemplate.hasKey(tokenKey2);
if (!token.contains(prefix) && !exist) {
......
......@@ -89,6 +89,7 @@ public class UserApiController implements IBaseController {
} else {
tokenKey2 = Constants.Session.USER_SESSION_CACHE + tenantId + ":" + token;
}
log.info("获取token key,token:{},tokenKey:{}", token, tokenKey2);
// 判断token是否存在
boolean exist = stringRedisTemplate.hasKey(tokenKey) || stringRedisTemplate.hasKey(tokenKey2);
log.info("检查token:[{}]有效性[{}],延续生命期[{}]", token, exist, prolong);
......
......@@ -148,10 +148,12 @@ public class SessionServiceImpl implements ISessionService {
* @return redisKey. 用来标识这个渠道的用户 Session 是否存在
*/
private String generateLoginPropertiesKey(Long userId, LoginProperties properties, Integer tenantId) {
log.info("生成登录属性 key: userId:{}, properties:{}, tenantId:{}", userId, JSON.toJSONString(properties), tenantId);
String returnKey="";
if (ObjectUtils.isEmpty(properties.getTenantId())) {
return Constants.Session.USER_SESSION_ID_CACHE + ":" + userId + ":" + properties.getMerchantName() + ":" + properties.getCreatedFrom();
returnKey = Constants.Session.USER_SESSION_ID_CACHE + ":" + userId + ":" + properties.getMerchantName() + ":" + properties.getCreatedFrom();
} else if (properties.getTenantId().equals(0) || TenantUtil.TENANT_DEFAULT.equals(properties.getTenantId())) {
return Constants.Session.USER_SESSION_ID_CACHE + ":" + userId + ":" + properties.getMerchantName() + ":" + properties.getCreatedFrom();
returnKey = Constants.Session.USER_SESSION_ID_CACHE + ":" + userId + ":" + properties.getMerchantName() + ":" + properties.getCreatedFrom();
} else {
Integer key;
if (tenantId != null) {
......@@ -159,8 +161,11 @@ public class SessionServiceImpl implements ISessionService {
} else {
key = properties.getTenantId();
}
return Constants.Session.USER_SESSION_ID_CACHE + ":" + userId + ":" + properties.getMerchantName() + ":" + properties.getCreatedFrom() + ":" + key;
returnKey = Constants.Session.USER_SESSION_ID_CACHE + ":" + userId + ":" + properties.getMerchantName() + ":" + properties.getCreatedFrom() + ":" + key;
}
log.info("生成登录属性 key: userId:{}, properties:{}, tenantId{}:,returnKey:{}", userId, JSON.toJSONString(properties), tenantId, returnKey);
return returnKey;
}
private String findSessionValueBySessionId(String sessionId, Integer tenantId) {
......@@ -170,6 +175,7 @@ public class SessionServiceImpl implements ISessionService {
} else {
tokenKey2 = Constants.Session.USER_SESSION_CACHE + tenantId + ":" + sessionId;
}
log.info("获取token key,token:{},tokenKey:{}", sessionId, tokenKey2);
String result = stringRedisTemplate.opsForValue().get(tokenKey2);
return StringUtils.defaultString(result, "");
......@@ -231,7 +237,7 @@ public class SessionServiceImpl implements ISessionService {
} else {
key = Constants.Session.USER_SESSION_CACHE + tenantId + ":" + token;
}
log.info("获取token key,token:{},tokenKey:{}", token, key);
stringRedisTemplate.opsForValue().set(key, json,
time, TimeUnit.SECONDS);
if (sessionValue.getUser() != null) {
......@@ -312,6 +318,7 @@ public class SessionServiceImpl implements ISessionService {
} else {
tokenKey2 = Constants.Session.USER_SESSION_CACHE + tenantId + ":" + token;
}
log.info("获取token key,token:{},tokenKey:{}", token, tokenKey2);
return tokenKey2;
}
......@@ -387,6 +394,7 @@ public class SessionServiceImpl implements ISessionService {
} else {
tokenKey2 = Constants.Session.USER_SESSION_CACHE + tenantId + ":" + sessionStruct.getSid();
}
log.info("获取token key,token:{},tokenKey:{}", token, tokenKey2);
stringRedisTemplate.delete(tokenKey2);
......@@ -411,6 +419,7 @@ public class SessionServiceImpl implements ISessionService {
} else {
tokenKey2 = Constants.Session.USER_SESSION_CACHE + tenantId + ":" + token;
}
log.info("获取token key,token:{},tokenKey:{}", token, tokenKey2);
// 单用户单次访问的最大的平均访问时间 SESSION_EXCHANGE_VALID_TIME
// 获取下expire和SESSION_EXCHANGE_VALID_TIME的最小值
long expireTime = Math.min(expire, Constants.Session.SESSION_EXCHANGE_VALID_TIME);
......
......@@ -156,6 +156,7 @@ public class XyqbSessionContextHolder {
} else {
linkToken = Constants.Session.USER_SESSION_CACHE + tenantId + ":" + token;
}
log.info("获取token key,token:{},tokenKey:{}", token, linkToken);
String result = redisTemplate.opsForValue().get(linkToken);
if (StringUtils.isEmpty(result)) {
......@@ -178,6 +179,7 @@ public class XyqbSessionContextHolder {
sessionStruct.setSid(token);
sessionStruct.setValues(values);
sessionStruct.setExpire(redisTemplate.getExpire(Constants.Session.USER_SESSION_CACHE + token));
log.info("获取token key,token:{},tokenKey:{}", token, Constants.Session.USER_SESSION_CACHE + token);
return sessionStruct;
} catch (Exception e) {
log.warn("[XyqbSessionContextHolder][getXSessionFromRedis] 序列化SessionValue出错:Tokekn:{},linkTokekn:{},sessionValue:{}", token, linkToken, result, e);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment