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

日志打印

parent 9a37979b
...@@ -531,6 +531,7 @@ public class UserController implements IBaseController { ...@@ -531,6 +531,7 @@ public class UserController implements IBaseController {
} else { } else {
tokenKey2 = Constants.Session.USER_SESSION_CACHE + tenantId + ":" + token; tokenKey2 = Constants.Session.USER_SESSION_CACHE + tenantId + ":" + token;
} }
log.info("获取token key,token:{},tokenKey:{}", token, tokenKey2);
// 判断token是否存在 // 判断token是否存在
boolean exist = stringRedisTemplate.hasKey(tokenKey) || stringRedisTemplate.hasKey(tokenKey2); boolean exist = stringRedisTemplate.hasKey(tokenKey) || stringRedisTemplate.hasKey(tokenKey2);
if (!token.contains(prefix) && !exist) { if (!token.contains(prefix) && !exist) {
......
...@@ -89,6 +89,7 @@ public class UserApiController implements IBaseController { ...@@ -89,6 +89,7 @@ public class UserApiController implements IBaseController {
} else { } else {
tokenKey2 = Constants.Session.USER_SESSION_CACHE + tenantId + ":" + token; tokenKey2 = Constants.Session.USER_SESSION_CACHE + tenantId + ":" + token;
} }
log.info("获取token key,token:{},tokenKey:{}", token, tokenKey2);
// 判断token是否存在 // 判断token是否存在
boolean exist = stringRedisTemplate.hasKey(tokenKey) || stringRedisTemplate.hasKey(tokenKey2); boolean exist = stringRedisTemplate.hasKey(tokenKey) || stringRedisTemplate.hasKey(tokenKey2);
log.info("检查token:[{}]有效性[{}],延续生命期[{}]", token, exist, prolong); log.info("检查token:[{}]有效性[{}],延续生命期[{}]", token, exist, prolong);
......
...@@ -148,10 +148,12 @@ public class SessionServiceImpl implements ISessionService { ...@@ -148,10 +148,12 @@ public class SessionServiceImpl implements ISessionService {
* @return redisKey. 用来标识这个渠道的用户 Session 是否存在 * @return redisKey. 用来标识这个渠道的用户 Session 是否存在
*/ */
private String generateLoginPropertiesKey(Long userId, LoginProperties properties, Integer tenantId) { 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())) { 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())) { } 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 { } else {
Integer key; Integer key;
if (tenantId != null) { if (tenantId != null) {
...@@ -159,8 +161,11 @@ public class SessionServiceImpl implements ISessionService { ...@@ -159,8 +161,11 @@ public class SessionServiceImpl implements ISessionService {
} else { } else {
key = properties.getTenantId(); 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) { private String findSessionValueBySessionId(String sessionId, Integer tenantId) {
...@@ -170,6 +175,7 @@ public class SessionServiceImpl implements ISessionService { ...@@ -170,6 +175,7 @@ public class SessionServiceImpl implements ISessionService {
} else { } else {
tokenKey2 = Constants.Session.USER_SESSION_CACHE + tenantId + ":" + sessionId; tokenKey2 = Constants.Session.USER_SESSION_CACHE + tenantId + ":" + sessionId;
} }
log.info("获取token key,token:{},tokenKey:{}", sessionId, tokenKey2);
String result = stringRedisTemplate.opsForValue().get(tokenKey2); String result = stringRedisTemplate.opsForValue().get(tokenKey2);
return StringUtils.defaultString(result, ""); return StringUtils.defaultString(result, "");
...@@ -231,7 +237,7 @@ public class SessionServiceImpl implements ISessionService { ...@@ -231,7 +237,7 @@ public class SessionServiceImpl implements ISessionService {
} else { } else {
key = Constants.Session.USER_SESSION_CACHE + tenantId + ":" + token; key = Constants.Session.USER_SESSION_CACHE + tenantId + ":" + token;
} }
log.info("获取token key,token:{},tokenKey:{}", token, key);
stringRedisTemplate.opsForValue().set(key, json, stringRedisTemplate.opsForValue().set(key, json,
time, TimeUnit.SECONDS); time, TimeUnit.SECONDS);
if (sessionValue.getUser() != null) { if (sessionValue.getUser() != null) {
...@@ -312,6 +318,7 @@ public class SessionServiceImpl implements ISessionService { ...@@ -312,6 +318,7 @@ public class SessionServiceImpl implements ISessionService {
} else { } else {
tokenKey2 = Constants.Session.USER_SESSION_CACHE + tenantId + ":" + token; tokenKey2 = Constants.Session.USER_SESSION_CACHE + tenantId + ":" + token;
} }
log.info("获取token key,token:{},tokenKey:{}", token, tokenKey2);
return tokenKey2; return tokenKey2;
} }
...@@ -387,6 +394,7 @@ public class SessionServiceImpl implements ISessionService { ...@@ -387,6 +394,7 @@ public class SessionServiceImpl implements ISessionService {
} else { } else {
tokenKey2 = Constants.Session.USER_SESSION_CACHE + tenantId + ":" + sessionStruct.getSid(); tokenKey2 = Constants.Session.USER_SESSION_CACHE + tenantId + ":" + sessionStruct.getSid();
} }
log.info("获取token key,token:{},tokenKey:{}", token, tokenKey2);
stringRedisTemplate.delete(tokenKey2); stringRedisTemplate.delete(tokenKey2);
...@@ -411,6 +419,7 @@ public class SessionServiceImpl implements ISessionService { ...@@ -411,6 +419,7 @@ public class SessionServiceImpl implements ISessionService {
} else { } else {
tokenKey2 = Constants.Session.USER_SESSION_CACHE + tenantId + ":" + token; tokenKey2 = Constants.Session.USER_SESSION_CACHE + tenantId + ":" + token;
} }
log.info("获取token key,token:{},tokenKey:{}", token, tokenKey2);
// 单用户单次访问的最大的平均访问时间 SESSION_EXCHANGE_VALID_TIME // 单用户单次访问的最大的平均访问时间 SESSION_EXCHANGE_VALID_TIME
// 获取下expire和SESSION_EXCHANGE_VALID_TIME的最小值 // 获取下expire和SESSION_EXCHANGE_VALID_TIME的最小值
long expireTime = Math.min(expire, Constants.Session.SESSION_EXCHANGE_VALID_TIME); long expireTime = Math.min(expire, Constants.Session.SESSION_EXCHANGE_VALID_TIME);
......
...@@ -156,6 +156,7 @@ public class XyqbSessionContextHolder { ...@@ -156,6 +156,7 @@ public class XyqbSessionContextHolder {
} else { } else {
linkToken = Constants.Session.USER_SESSION_CACHE + tenantId + ":" + token; linkToken = Constants.Session.USER_SESSION_CACHE + tenantId + ":" + token;
} }
log.info("获取token key,token:{},tokenKey:{}", token, linkToken);
String result = redisTemplate.opsForValue().get(linkToken); String result = redisTemplate.opsForValue().get(linkToken);
if (StringUtils.isEmpty(result)) { if (StringUtils.isEmpty(result)) {
...@@ -178,6 +179,7 @@ public class XyqbSessionContextHolder { ...@@ -178,6 +179,7 @@ public class XyqbSessionContextHolder {
sessionStruct.setSid(token); sessionStruct.setSid(token);
sessionStruct.setValues(values); sessionStruct.setValues(values);
sessionStruct.setExpire(redisTemplate.getExpire(Constants.Session.USER_SESSION_CACHE + token)); 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; return sessionStruct;
} catch (Exception e) { } catch (Exception e) {
log.warn("[XyqbSessionContextHolder][getXSessionFromRedis] 序列化SessionValue出错:Tokekn:{},linkTokekn:{},sessionValue:{}", token, linkToken, result, 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