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
178e8a4b
Commit
178e8a4b
authored
May 15, 2020
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
设置打包时可以通过GIT查看源码
parent
6d6a8bcf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
13 deletions
+45
-13
TypeHelper.java
...src/main/java/com/yanzuoguang/util/helper/TypeHelper.java
+43
-0
WebAspect.java
...ud/src/main/java/com/yanzuoguang/cloud/aop/WebAspect.java
+2
-13
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/TypeHelper.java
0 → 100644
View file @
178e8a4b
package
com
.
yanzuoguang
.
util
.
helper
;
import
com.yanzuoguang.util.vo.ResponseResult
;
import
java.lang.reflect.ParameterizedType
;
import
java.lang.reflect.Type
;
/**
* 类型帮助类
*
* @author 颜佐光
*/
public
class
TypeHelper
{
/**
* 判断是否属于子类
*
* @param from
* @param to
* @return
*/
public
static
boolean
isSubType
(
Type
from
,
Class
to
)
{
Class
returnClass
=
getClass
(
from
);
boolean
isResponseResult
=
returnClass
!=
null
&&
returnClass
.
isAssignableFrom
(
ResponseResult
.
class
);
return
isResponseResult
;
}
/**
* 获取type的class
*
* @param type
* @return
*/
public
static
Class
getClass
(
Type
type
)
{
if
(
type
instanceof
ParameterizedType
)
{
Type
rawType
=
((
ParameterizedType
)
type
).
getRawType
();
return
getClass
(
rawType
);
}
else
if
(
type
instanceof
Class
)
{
return
(
Class
)
type
;
}
return
null
;
}
}
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/aop/WebAspect.java
View file @
178e8a4b
...
@@ -3,6 +3,7 @@ package com.yanzuoguang.cloud.aop;
...
@@ -3,6 +3,7 @@ package com.yanzuoguang.cloud.aop;
import
com.yanzuoguang.cloud.service.TokenServiceCall
;
import
com.yanzuoguang.cloud.service.TokenServiceCall
;
import
com.yanzuoguang.token.TokenHelper
;
import
com.yanzuoguang.token.TokenHelper
;
import
com.yanzuoguang.util.exception.ExceptionHelper
;
import
com.yanzuoguang.util.exception.ExceptionHelper
;
import
com.yanzuoguang.util.helper.TypeHelper
;
import
com.yanzuoguang.util.log.Log
;
import
com.yanzuoguang.util.log.Log
;
import
com.yanzuoguang.util.vo.ResponseResult
;
import
com.yanzuoguang.util.vo.ResponseResult
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.ProceedingJoinPoint
;
...
@@ -102,9 +103,7 @@ public class WebAspect extends BaseRequestAspect {
...
@@ -102,9 +103,7 @@ public class WebAspect extends BaseRequestAspect {
ex
=
e
;
ex
=
e
;
result
=
ExceptionHelper
.
getError
(
e
);
result
=
ExceptionHelper
.
getError
(
e
);
Type
returnType
=
getReturnType
(
joinPoint
);
Type
returnType
=
getReturnType
(
joinPoint
);
Class
returnClass
=
getClass
(
returnType
);
if
(
TypeHelper
.
isSubType
(
returnType
,
ResponseResult
.
class
))
{
boolean
isResponseResult
=
returnClass
!=
null
&&
returnClass
.
isAssignableFrom
(
ResponseResult
.
class
);
if
(
isResponseResult
)
{
return
result
;
return
result
;
}
else
{
}
else
{
throw
e
;
throw
e
;
...
@@ -118,16 +117,6 @@ public class WebAspect extends BaseRequestAspect {
...
@@ -118,16 +117,6 @@ public class WebAspect extends BaseRequestAspect {
}
}
}
}
private
Class
getClass
(
Type
type
)
{
if
(
type
instanceof
ParameterizedType
)
{
Type
rawType
=
((
ParameterizedType
)
type
).
getRawType
();
return
getClass
(
rawType
);
}
else
if
(
type
instanceof
Class
)
{
return
(
Class
)
type
;
}
return
null
;
}
/**
/**
* 是否属于网关服务,网关服务不进行监控
* 是否属于网关服务,网关服务不进行监控
*
*
...
...
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