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
5a780e07
Commit
5a780e07
authored
Jan 27, 2022
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
下载视频
parent
87e374fe
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
13 deletions
+27
-13
TokenHelper.java
...l-db/src/main/java/com/yanzuoguang/token/TokenHelper.java
+27
-13
No files found.
yzg-util-db/src/main/java/com/yanzuoguang/token/TokenHelper.java
View file @
5a780e07
...
...
@@ -3,7 +3,6 @@ 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.exception.CodeException
;
import
com.yanzuoguang.util.helper.JsonHelper
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.vo.MapRow
;
...
...
@@ -73,6 +72,18 @@ public class TokenHelper {
* @return 缓存的数据
*/
public
static
<
T
extends
Object
>
T
get
(
boolean
checkFlag
,
Class
<
T
>
cls
)
{
return
get
(
checkFlag
,
cls
,
true
);
}
/**
* 获取当前的登录信息
*
* @param checkFlag 是否抛出异常
* @param cls 需要获取的数据的类型
* @param <T> 数据类型
* @return 缓存的数据
*/
public
static
<
T
extends
Object
>
T
get
(
boolean
checkFlag
,
Class
<
T
>
cls
,
boolean
readNewToken
)
{
String
id
=
getCurrentId
();
TokenData
tokenData
=
cache
.
get
(
id
);
if
(
tokenData
==
null
)
{
...
...
@@ -81,6 +92,8 @@ public class TokenHelper {
}
return
null
;
}
// 获取最新的token
if
(
readNewToken
)
{
boolean
isEmpty
=
tokenData
.
getData
()
==
null
||
tokenData
.
getData
().
isEmpty
();
boolean
isExpire
=
tokenData
.
getExpire
()
<
System
.
currentTimeMillis
();
boolean
isToken
=
!
StringHelper
.
isEmpty
(
tokenData
.
getToken
())
&&
(
isEmpty
||
isExpire
);
...
...
@@ -96,6 +109,7 @@ public class TokenHelper {
}
return
null
;
}
}
if
(
ObjectHelper
.
isSub
(
cls
,
tokenData
.
getData
().
getClass
()))
{
return
(
T
)
tokenData
.
getData
();
...
...
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