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
ce382c60
Commit
ce382c60
authored
Mar 22, 2021
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
不记录系统日志
parent
df1fdbd7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
14 deletions
+52
-14
ArrayHelper.java
...rc/main/java/com/yanzuoguang/util/helper/ArrayHelper.java
+30
-0
BaseRequestAspect.java
...ain/java/com/yanzuoguang/cloud/aop/BaseRequestAspect.java
+21
-13
WebAspect.java
...ud/src/main/java/com/yanzuoguang/cloud/aop/WebAspect.java
+1
-1
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/ArrayHelper.java
View file @
ce382c60
...
...
@@ -87,5 +87,35 @@ public class ArrayHelper {
return
list
;
}
/**
* 将数组添加到列表中
*
* @param list
* @param from
* @param <T>
*/
public
static
final
<
T
extends
Object
>
void
addList
(
List
<
T
>
list
,
T
[]...
from
)
{
for
(
T
[]
item
:
from
)
{
for
(
T
sub
:
item
)
{
list
.
add
(
sub
);
}
}
}
/**
* 将数组添加到列表中
*
* @param list
* @param from
* @param <T>
*/
public
static
final
<
T
extends
Object
>
void
addList
(
List
<
T
>
list
,
List
<
T
>...
from
)
{
for
(
List
<
T
>
item
:
from
)
{
for
(
T
sub
:
item
)
{
list
.
add
(
sub
);
}
}
}
}
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/aop/BaseRequestAspect.java
View file @
ce382c60
...
...
@@ -2,6 +2,7 @@ package com.yanzuoguang.cloud.aop;
import
com.rabbitmq.client.Channel
;
import
com.yanzuoguang.util.exception.ExceptionHelper
;
import
com.yanzuoguang.util.helper.ArrayHelper
;
import
com.yanzuoguang.util.helper.JsonHelper
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.log.Log
;
...
...
@@ -22,6 +23,7 @@ import org.springframework.web.multipart.MultipartFile;
import
javax.servlet.http.HttpServlet
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.lang.annotation.Annotation
;
import
java.lang.reflect.Method
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -234,30 +236,34 @@ public class BaseRequestAspect {
String
name
=
signature
.
getName
();
FeignClient
feignClient
=
(
FeignClient
)
declaringType
.
getAnnotation
(
FeignClient
.
class
);
if
(
feignClient
!=
null
&&
signature
instanceof
MethodSignature
)
{
// 类路径
RequestMapping
[]
classRequests
=
(
RequestMapping
[])
declaringType
.
getAnnotationsByType
(
RequestMapping
.
class
);
PostMapping
[]
classPosts
=
(
PostMapping
[])
declaringType
.
getAnnotationsByType
(
PostMapping
.
class
);
GetMapping
[]
classGets
=
(
GetMapping
[])
declaringType
.
getAnnotationsByType
(
GetMapping
.
class
);
List
<
Annotation
>
annotation
=
new
ArrayList
<>();
ArrayHelper
.
addList
(
annotation
,
classRequests
,
classPosts
,
classGets
);
String
baseUrl
=
String
.
format
(
"%s.%s"
,
declaringType
.
getSimpleName
(),
name
);
if
(!
annotation
.
isEmpty
()
&&
signature
instanceof
MethodSignature
)
{
MethodSignature
methodSignature
=
(
MethodSignature
)
signature
;
Method
targetMethod
=
methodSignature
.
getMethod
();
// 类路径
RequestMapping
[]
classRequests
=
(
RequestMapping
[])
declaringType
.
getAnnotationsByType
(
RequestMapping
.
class
);
PostMapping
[]
classPosts
=
(
PostMapping
[])
declaringType
.
getAnnotationsByType
(
PostMapping
.
class
);
GetMapping
[]
classGets
=
(
GetMapping
[])
declaringType
.
getAnnotationsByType
(
GetMapping
.
class
);
// 方法路径
RequestMapping
[]
requests
=
targetMethod
.
getAnnotationsByType
(
RequestMapping
.
class
);
PostMapping
[]
posts
=
targetMethod
.
getAnnotationsByType
(
PostMapping
.
class
);
GetMapping
[]
gets
=
targetMethod
.
getAnnotationsByType
(
GetMapping
.
class
);
url
=
getFeignUrl
(
feignClient
,
classRequests
,
classPosts
,
classGets
,
requests
,
posts
,
gets
);
url
=
getFeign
OrRequest
Url
(
feignClient
,
classRequests
,
classPosts
,
classGets
,
requests
,
posts
,
gets
);
}
else
{
Message
message
=
getMessage
(
joinPoint
.
getArgs
());
if
(
message
!=
null
)
{
url
=
message
.
getMessageProperties
().
getConsumerQueue
();
}
}
if
(
StringHelper
.
isEmpty
(
url
))
{
url
=
String
.
format
(
"%s.%s"
,
declaringType
.
getSimpleName
(),
name
)
;
return
baseUrl
;
}
return
url
;
return
String
.
format
(
"%s:%s"
,
baseUrl
,
url
)
;
}
/**
...
...
@@ -272,11 +278,13 @@ public class BaseRequestAspect {
* @param gets
* @return
*/
private
String
getFeignUrl
(
FeignClient
feignClient
,
RequestMapping
[]
classRequests
,
PostMapping
[]
classPosts
,
GetMapping
[]
classGets
,
RequestMapping
[]
requests
,
PostMapping
[]
posts
,
GetMapping
[]
gets
)
{
private
String
getFeign
OrRequest
Url
(
FeignClient
feignClient
,
RequestMapping
[]
classRequests
,
PostMapping
[]
classPosts
,
GetMapping
[]
classGets
,
RequestMapping
[]
requests
,
PostMapping
[]
posts
,
GetMapping
[]
gets
)
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
feignClient
.
value
());
if
(
feignClient
!=
null
)
{
sb
.
append
(
feignClient
.
value
());
}
if
(
classRequests
!=
null
)
{
for
(
RequestMapping
item
:
classRequests
)
{
sb
.
append
(
item
.
value
()[
0
]);
...
...
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/aop/WebAspect.java
View file @
ce382c60
...
...
@@ -73,7 +73,7 @@ public class WebAspect extends BaseRequestAspect {
LogVo
log
=
null
;
boolean
clear
=
requestLogInit
();
long
start
=
System
.
currentTimeMillis
();
String
url
=
HttpAspectUtil
.
getHttpRequestUrl
(
);
String
url
=
getMethodUrl
(
joinPoint
);
if
(
clear
)
{
log
=
startLog
(
TAG
,
url
,
getRequestBody
(
joinPoint
));
clear
=
clear
&&
log
!=
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