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
ca89c8d4
Commit
ca89c8d4
authored
Oct 09, 2019
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接口文档的支持
parent
1b0bf04f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
7 deletions
+38
-7
WebAspect.java
...ud/src/main/java/com/yanzuoguang/cloud/aop/WebAspect.java
+9
-4
TokenService.java
...main/java/com/yanzuoguang/cloud/service/TokenService.java
+1
-1
TokenServiceCall.java
.../java/com/yanzuoguang/cloud/service/TokenServiceCall.java
+28
-2
No files found.
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/aop/WebAspect.java
View file @
ca89c8d4
...
...
@@ -49,6 +49,8 @@ public class WebAspect extends BaseRequestAspect {
public
void
webAspect
()
{
}
/**
* 执行环形切面
*
...
...
@@ -64,9 +66,10 @@ public class WebAspect extends BaseRequestAspect {
Exception
ex
=
null
;
Ref
<
Boolean
>
flag
=
new
Ref
<>(
false
);
boolean
isGateWay
=
isGateWay
();
boolean
isInit
=
false
;
try
{
if
(!
isGateWay
)
{
tokenServiceCall
.
tokenInit
();
isInit
=
tokenServiceCall
.
tokenInit
();
}
result
=
executeMethod
(
joinPoint
);
if
(!
isGateWay
)
{
...
...
@@ -82,10 +85,12 @@ public class WebAspect extends BaseRequestAspect {
throw
e
;
}
}
finally
{
if
(
isInit
){
if
(!
isGateWay
)
{
tokenFinish
(
flag
);
}
TokenHelper
.
remove
();
}
responseLog
(
clear
,
TAG
,
HttpAspectUtil
.
getHttpRequestUrl
(),
joinPoint
,
start
,
result
,
ex
);
}
}
...
...
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/service/TokenService.java
View file @
ca89c8d4
...
...
@@ -12,7 +12,7 @@ public interface TokenService extends TokenLoad {
/**
* 初始化token
*/
boolean
tokenInit
();
void
tokenInit
();
/**
* 结束token
...
...
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/service/TokenServiceCall.java
View file @
ca89c8d4
...
...
@@ -3,7 +3,10 @@ package com.yanzuoguang.cloud.service;
import
com.yanzuoguang.token.TokenData
;
import
com.yanzuoguang.token.TokenHelper
;
import
com.yanzuoguang.token.TokenLoad
;
import
com.yanzuoguang.util.cache.MemoryCache
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.log.Log
;
import
com.yanzuoguang.util.thread.ThreadHelper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.stereotype.Component
;
...
...
@@ -23,6 +26,8 @@ public class TokenServiceCall implements TokenLoad {
private
int
flagCount
=
3
;
private
MemoryCache
<
Boolean
>
countCache
=
new
MemoryCache
<>();
public
TokenServiceCall
()
{
TokenHelper
.
setTokenLoad
(
this
);
}
...
...
@@ -46,12 +51,17 @@ public class TokenServiceCall implements TokenLoad {
/**
* 请求时初始化token
*/
public
void
tokenInit
()
{
public
boolean
tokenInit
()
{
init
();
if
(
tokenService
==
null
)
{
return
;
return
false
;
}
if
(
isHave
())
{
return
false
;
}
tokenService
.
tokenInit
();
setHave
();
return
true
;
}
/**
...
...
@@ -63,6 +73,7 @@ public class TokenServiceCall implements TokenLoad {
return
;
}
tokenService
.
tokenFinish
();
removeHave
();
}
/**
...
...
@@ -79,4 +90,19 @@ public class TokenServiceCall implements TokenLoad {
}
return
tokenService
.
load
(
token
);
}
private
boolean
isHave
()
{
String
id
=
StringHelper
.
toString
(
Thread
.
currentThread
().
getId
());
return
StringHelper
.
toBoolean
(
countCache
.
get
(
id
));
}
private
void
setHave
()
{
String
id
=
StringHelper
.
toString
(
Thread
.
currentThread
().
getId
());
countCache
.
put
(
id
,
true
);
}
private
void
removeHave
()
{
String
id
=
StringHelper
.
toString
(
Thread
.
currentThread
().
getId
());
countCache
.
remove
(
id
);
}
}
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