Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
head_group
xyqb-user2
Commits
18a27186
Commit
18a27186
authored
May 30, 2018
by
xiaoguang.xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix : 提升logAspect使用体验...
parent
4590ca42
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
15 deletions
+24
-15
LogCallHttpAspect.java
...n/quantgroup/xyqb/aspect/logcaller/LogCallHttpAspect.java
+18
-11
AppController.java
...antgroup/xyqb/controller/external/user/AppController.java
+6
-4
No files found.
src/main/java/cn/quantgroup/xyqb/aspect/logcaller/LogCallHttpAspect.java
View file @
18a27186
package
cn
.
quantgroup
.
xyqb
.
aspect
.
logcaller
;
import
cn.quantgroup.xyqb.util.IPUtil
;
import
com.google.common.base.Stopwatch
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
...
...
@@ -14,7 +15,7 @@ import org.springframework.web.context.request.RequestContextHolder;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.
Objects
;
import
java.util.
concurrent.TimeUnit
;
/**
* 调用者记录
...
...
@@ -34,17 +35,23 @@ public class LogCallHttpAspect {
@Around
(
"logHttpCaller()"
)
public
Object
record
(
ProceedingJoinPoint
pjp
)
throws
Throwable
{
Object
result
=
pjp
.
proce
ed
();
Stopwatch
stopwatch
=
Stopwatch
.
createStart
ed
();
ServletRequestAttributes
attrs
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
if
(
Objects
.
nonNull
(
attrs
))
{
try
{
HttpServletRequest
request
=
attrs
.
getRequest
();
String
remoteIP
=
IPUtil
.
getRemoteIP
(
request
);
Object
[]
args
=
pjp
.
getArgs
();
LOGGER
.
info
(
"http api is called,from IP:[{}],args:[{}]"
,
remoteIP
,
args
);
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"打印http请求日志出错"
,
e
);
}
HttpServletRequest
request
=
attrs
.
getRequest
();
String
remoteIP
=
IPUtil
.
getRemoteIP
(
request
);
Object
[]
args
=
pjp
.
getArgs
();
boolean
hasException
=
false
;
Object
result
;
try
{
result
=
pjp
.
proceed
();
}
catch
(
Throwable
e
)
{
hasException
=
true
;
throw
e
;
}
finally
{
Stopwatch
stop
=
stopwatch
.
stop
();
long
elapsed
=
stop
.
elapsed
(
TimeUnit
.
MILLISECONDS
);
LOGGER
.
info
(
"[httpRequestLog],url:[{}],remoteIP:[{}],args:[{}],duration:[{}],exception:[{}]"
,
request
.
getRequestURL
(),
remoteIP
,
args
,
elapsed
,
hasException
);
}
return
result
;
}
...
...
src/main/java/cn/quantgroup/xyqb/controller/external/user/AppController.java
View file @
18a27186
...
...
@@ -14,6 +14,7 @@ import cn.quantgroup.xyqb.service.user.IUserService;
import
cn.quantgroup.xyqb.util.IPUtil
;
import
cn.quantgroup.xyqb.util.MqUtils
;
import
cn.quantgroup.xyqb.util.ValidationUtil
;
import
io.swagger.annotations.ApiOperation
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -63,6 +64,7 @@ public class AppController implements IBaseController {
@IpValidator
@RequestMapping
(
"/login"
)
@ApiOperation
(
value
=
"/login"
,
notes
=
"App登陆"
)
public
JsonResult
login
(
String
phoneNo
,
String
idNo
,
String
name
,
String
key
,
...
...
@@ -162,10 +164,10 @@ public class AppController implements IBaseController {
context
.
setAppChannel
(
appChannel
);
loginInfo
.
setLoginContext
(
context
);
LOGGER
.
info
(
"第三方用户获取信息登录成功 [AppController] loginSuper --> loginFrom:{}, phoneNo:{},appChannel:{},channelId:{}"
,
registerFrom
,
phoneNo
,
appChannel
,
channelId
);
/*
* 部分免密渠道登录统计,用户中心不需识别,由统计平台来过滤
* 贷款导航(84660);壹账通H5(159384)
*/
/*
* 部分免密渠道登录统计,用户中心不需识别,由统计平台来过滤
* 贷款导航(84660);壹账通H5(159384)
*/
user
.
setRegisteredFrom
(
registerFrom
);
UserStatistics
statistics
=
new
UserStatistics
(
user
,
null
,
4
,
channelId
);
//增加登陆统计发送
...
...
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