Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
head_group
xyqb-user2
Commits
191cb5e7
Commit
191cb5e7
authored
Mar 27, 2025
by
xuepeng.chang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
日志打印
parent
9a37979b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
4 deletions
+17
-4
UserController.java
...n/quantgroup/xyqb/controller/external/UserController.java
+1
-0
UserApiController.java
...roup/xyqb/controller/internal/user/UserApiController.java
+1
-0
SessionServiceImpl.java
...ntgroup/xyqb/service/session/impl/SessionServiceImpl.java
+13
-4
XyqbSessionContextHolder.java
.../cn/quantgroup/xyqb/session/XyqbSessionContextHolder.java
+2
-0
No files found.
src/main/java/cn/quantgroup/xyqb/controller/external/UserController.java
View file @
191cb5e7
...
...
@@ -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
)
{
...
...
src/main/java/cn/quantgroup/xyqb/controller/internal/user/UserApiController.java
View file @
191cb5e7
...
...
@@ -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
);
...
...
src/main/java/cn/quantgroup/xyqb/service/session/impl/SessionServiceImpl.java
View file @
191cb5e7
...
...
@@ -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
();
return
Key
=
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
();
return
Key
=
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
);
...
...
src/main/java/cn/quantgroup/xyqb/session/XyqbSessionContextHolder.java
View file @
191cb5e7
...
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment