Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wwwanlingxiao
mall
Commits
0e8fa6c8
You need to sign in or sign up before continuing.
Commit
0e8fa6c8
authored
Jun 27, 2019
by
macro
Browse files
Update WebLogAspect.java
parent
5ada8a3d
Changes
1
Hide whitespace changes
Inline
Side-by-side
mall-admin/src/main/java/com/macro/mall/component/WebLogAspect.java
View file @
0e8fa6c8
...
@@ -39,7 +39,6 @@ import java.util.Map;
...
@@ -39,7 +39,6 @@ import java.util.Map;
@Order
(
1
)
@Order
(
1
)
public
class
WebLogAspect
{
public
class
WebLogAspect
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
WebLogAspect
.
class
);
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
WebLogAspect
.
class
);
private
ThreadLocal
<
Long
>
startTime
=
new
ThreadLocal
<>();
@Pointcut
(
"execution(public * com.macro.mall.controller.*.*(..))"
)
@Pointcut
(
"execution(public * com.macro.mall.controller.*.*(..))"
)
public
void
webLog
()
{
public
void
webLog
()
{
...
@@ -47,7 +46,6 @@ public class WebLogAspect {
...
@@ -47,7 +46,6 @@ public class WebLogAspect {
@Before
(
"webLog()"
)
@Before
(
"webLog()"
)
public
void
doBefore
(
JoinPoint
joinPoint
)
throws
Throwable
{
public
void
doBefore
(
JoinPoint
joinPoint
)
throws
Throwable
{
startTime
.
set
(
System
.
currentTimeMillis
());
}
}
@AfterReturning
(
value
=
"webLog()"
,
returning
=
"ret"
)
@AfterReturning
(
value
=
"webLog()"
,
returning
=
"ret"
)
...
@@ -56,6 +54,7 @@ public class WebLogAspect {
...
@@ -56,6 +54,7 @@ public class WebLogAspect {
@Around
(
"webLog()"
)
@Around
(
"webLog()"
)
public
Object
doAround
(
ProceedingJoinPoint
joinPoint
)
throws
Throwable
{
public
Object
doAround
(
ProceedingJoinPoint
joinPoint
)
throws
Throwable
{
long
startTime
=
System
.
currentTimeMillis
();
//获取当前请求对象
//获取当前请求对象
ServletRequestAttributes
attributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
ServletRequestAttributes
attributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
HttpServletRequest
request
=
attributes
.
getRequest
();
HttpServletRequest
request
=
attributes
.
getRequest
();
...
@@ -76,8 +75,8 @@ public class WebLogAspect {
...
@@ -76,8 +75,8 @@ public class WebLogAspect {
webLog
.
setMethod
(
request
.
getMethod
());
webLog
.
setMethod
(
request
.
getMethod
());
webLog
.
setParameter
(
getParameter
(
method
,
joinPoint
.
getArgs
()));
webLog
.
setParameter
(
getParameter
(
method
,
joinPoint
.
getArgs
()));
webLog
.
setResult
(
result
);
webLog
.
setResult
(
result
);
webLog
.
setSpendTime
((
int
)
(
endTime
-
startTime
.
get
()
));
webLog
.
setSpendTime
((
int
)
(
endTime
-
startTime
));
webLog
.
setStartTime
(
startTime
.
get
()
);
webLog
.
setStartTime
(
startTime
);
webLog
.
setUri
(
request
.
getRequestURI
());
webLog
.
setUri
(
request
.
getRequestURI
());
webLog
.
setUrl
(
request
.
getRequestURL
().
toString
());
webLog
.
setUrl
(
request
.
getRequestURL
().
toString
());
Map
<
String
,
Object
>
logMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
logMap
=
new
HashMap
<>();
...
...
Write
Preview
Supports
Markdown
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