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
a106f9bd
Commit
a106f9bd
authored
Jun 11, 2019
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
常规BUG的修改
parent
5d4ff0f8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
3 deletions
+38
-3
WebAspect.java
...ud/src/main/java/com/yanzuoguang/cloud/aop/WebAspect.java
+38
-3
No files found.
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/aop/WebAspect.java
View file @
a106f9bd
...
...
@@ -19,6 +19,7 @@ import org.aspectj.lang.reflect.MethodSignature;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
javax.servlet.ServletRequest
;
...
...
@@ -41,6 +42,9 @@ public class WebAspect extends BaseRequestAspect {
@Autowired
private
TokenServiceCall
tokenServiceCall
;
@Value
(
"${yzg.reqUrl:order,check,use}"
)
private
String
reqUrl
;
/**
* exec aop point aspect
*/
...
...
@@ -115,19 +119,50 @@ public class WebAspect extends BaseRequestAspect {
* @throws NoSuchMethodException
*/
private
Type
getReturnType
(
ProceedingJoinPoint
joinPoint
)
{
Method
m
=
getMethod
(
joinPoint
);
Type
t
=
m
.
getAnnotatedReturnType
().
getType
();
return
t
;
}
/**
* 获取返回的至类型
*
* @param joinPoint
* @return
* @throws NoSuchMethodException
*/
private
Method
getMethod
(
ProceedingJoinPoint
joinPoint
)
{
//获取返回值类型
Signature
s
=
joinPoint
.
getSignature
();
MethodSignature
ms
=
(
MethodSignature
)
s
;
Method
m
=
ms
.
getMethod
();
Type
t
=
m
.
getAnnotatedReturnType
().
getType
();
return
t
;
return
m
;
}
/**
* 执行方法
*
* @param joinPoint 需要执行的方法
* @param name 方法名称
* @return 返回结果
* @throws Throwable
*/
private
Object
executeMethod
(
ProceedingJoinPoint
joinPoint
,
String
name
)
throws
Throwable
{
boolean
dataArgs
=
joinPoint
.
getArgs
().
length
!=
1
||
joinPoint
.
getArgs
().
length
==
1
&&
(
joinPoint
.
getArgs
()[
0
]
instanceof
ServletResponse
||
joinPoint
.
getArgs
()[
0
]
instanceof
ServletRequest
);
if
(
dataArgs
)
{
Method
method
=
getMethod
(
joinPoint
);
boolean
isUrl
=
false
;
if
(!
StringHelper
.
isEmpty
(
reqUrl
))
{
String
[]
urls
=
reqUrl
.
split
(
","
);
for
(
String
url
:
urls
)
{
if
(
method
.
getName
().
matches
(
url
))
{
isUrl
=
true
;
break
;
}
}
}
if
(
dataArgs
||
!
isUrl
)
{
return
joinPoint
.
proceed
();
}
else
{
// 获取请求编号
...
...
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