Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
YZG
yzg-util
Commits
0eb470e6
Commit
0eb470e6
authored
Feb 05, 2024
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
身份证识别
parent
abd36a95
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
TokenHelper.java
...l-db/src/main/java/com/yanzuoguang/token/TokenHelper.java
+12
-12
No files found.
yzg-util-db/src/main/java/com/yanzuoguang/token/TokenHelper.java
View file @
0eb470e6
...
...
@@ -2,10 +2,10 @@ package com.yanzuoguang.token;
import
com.yanzuoguang.util.YzgError
;
import
com.yanzuoguang.util.base.ObjectHelper
;
import
com.yanzuoguang.util.cache.MemoryCache
;
import
com.yanzuoguang.util.helper.JsonHelper
;
import
com.yanzuoguang.util.helper.RsaHelper
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.log.Log
;
import
com.yanzuoguang.util.vo.MapRow
;
/**
...
...
@@ -41,7 +41,7 @@ public class TokenHelper {
/**
* 内存缓存
*/
protected
final
static
MemoryCache
<
TokenData
>
cache
=
new
MemoryCache
<>();
protected
final
static
ThreadLocal
<
TokenData
>
cache
=
new
ThreadLocal
<>();
/**
...
...
@@ -59,8 +59,7 @@ public class TokenHelper {
* @return 缓存的数据
*/
public
static
TokenData
getTokenData
(
boolean
readNewToken
)
{
String
id
=
getCurrentId
();
TokenData
cacheTokenData
=
cache
.
get
(
id
);
TokenData
cacheTokenData
=
cache
.
get
();
if
(
cacheTokenData
==
null
)
{
return
null
;
}
...
...
@@ -77,7 +76,7 @@ public class TokenHelper {
if
(
databaseToken
==
null
||
databaseToken
.
getData
()
==
null
)
{
return
null
;
}
else
{
cache
.
put
(
id
,
databaseToken
);
cache
.
set
(
databaseToken
);
return
databaseToken
;
}
}
...
...
@@ -116,7 +115,9 @@ public class TokenHelper {
* @return 缓存的数据
*/
public
static
<
T
>
T
get
(
boolean
checkFlag
,
Class
<
T
>
cls
,
boolean
readNewToken
)
{
Log
.
info
(
TokenHelper
.
class
,
"获取登陆信息结果"
);
TokenData
tokenData
=
getTokenData
(
readNewToken
);
Log
.
info
(
TokenHelper
.
class
,
"获取登陆信息结果"
);
if
(
tokenData
==
null
)
{
if
(
checkFlag
)
{
throw
YzgError
.
getRuntimeException
(
"061"
);
...
...
@@ -243,10 +244,11 @@ public class TokenHelper {
* @param tokenString 登录标记字符串
*/
public
static
TokenData
setTokenString
(
String
tokenString
)
{
String
id
=
getCurrentId
();
TokenData
tokenData
=
JsonHelper
.
deserialize
(
tokenString
,
TokenData
.
class
);
cache
.
put
(
id
,
tokenData
);
if
(
tokenData
!=
null
)
{
tokenData
.
setWrite
(
false
);
}
cache
.
set
(
tokenData
);
return
tokenData
;
}
...
...
@@ -256,8 +258,7 @@ public class TokenHelper {
* @return 登录标记字符粗
*/
public
static
String
getTokenString
()
{
String
id
=
getCurrentId
();
TokenData
tokenData
=
cache
.
get
(
id
);
TokenData
tokenData
=
cache
.
get
();
if
(
tokenData
==
null
)
{
return
StringHelper
.
EMPTY
;
}
...
...
@@ -269,7 +270,6 @@ public class TokenHelper {
* 删除缓存信息
*/
public
static
void
remove
()
{
String
id
=
getCurrentId
();
cache
.
remove
(
id
);
cache
.
remove
();
}
}
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