Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
shop
Project
Project
Details
Activity
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
曲欣亮
shop
Commits
5e046d30
Commit
5e046d30
authored
Oct 18, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
13415909
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
14 deletions
+23
-14
LogInterceptor.java
...ava/com/egolm/shop/config/interceptor/LogInterceptor.java
+20
-14
application.properties
src/main/resources/application.properties
+3
-0
No files found.
src/main/java/com/egolm/shop/config/interceptor/LogInterceptor.java
View file @
5e046d30
...
...
@@ -9,6 +9,7 @@ import javax.servlet.http.HttpServletResponse;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.servlet.handler.HandlerInterceptorAdapter
;
...
...
@@ -18,6 +19,9 @@ import com.egolm.common.web.ServletUtil;
@Component
public
class
LogInterceptor
extends
HandlerInterceptorAdapter
{
@Value
(
"${log.isOpen}"
)
private
Boolean
isOpen
;
@Override
public
boolean
preHandle
(
HttpServletRequest
req
,
HttpServletResponse
resp
,
Object
handler
)
throws
Exception
{
...
...
@@ -30,20 +34,22 @@ public class LogInterceptor extends HandlerInterceptorAdapter {
private
JdbcTemplate
jdbcTemplate
;
private
void
exec
(
HttpServletRequest
req
)
{
try
{
String
contextPath
=
req
.
getContextPath
();
String
uri
=
req
.
getRequestURI
().
substring
(
contextPath
.
length
());
String
remoteIp
=
ServletUtil
.
remoteIp
(
req
);
String
params
=
JSON
.
toJSONString
(
req
.
getParameterMap
());
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"sProjectID"
,
"SHOP"
);
map
.
put
(
"sURI"
,
uri
);
map
.
put
(
"sClientIP"
,
remoteIp
);
map
.
put
(
"sParams"
,
params
);
map
.
put
(
"dCreateTime"
,
new
Date
());
jdbcTemplate
.
save
(
"tShopLog"
,
map
);
}
catch
(
Throwable
e
)
{
e
.
printStackTrace
();
if
(
isOpen
)
{
try
{
String
contextPath
=
req
.
getContextPath
();
String
uri
=
req
.
getRequestURI
().
substring
(
contextPath
.
length
());
String
remoteIp
=
ServletUtil
.
remoteIp
(
req
);
String
params
=
JSON
.
toJSONString
(
req
.
getParameterMap
());
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"sProjectID"
,
"SHOP"
);
map
.
put
(
"sURI"
,
uri
);
map
.
put
(
"sClientIP"
,
remoteIp
);
map
.
put
(
"sParams"
,
params
);
map
.
put
(
"dCreateTime"
,
new
Date
());
jdbcTemplate
.
save
(
"tShopLog"
,
map
);
}
catch
(
Throwable
e
)
{
e
.
printStackTrace
();
}
}
}
...
...
src/main/resources/application.properties
View file @
5e046d30
...
...
@@ -45,6 +45,7 @@ spring.datasource.validationQuery=SELECT 1
spring.datasource.timeBetweenEvictionRunsMillis
=
3600000
spring.datasource.filters
=
stat,log4j
log.isOpen
=
false
log.datasource.username
=
ERP
log.datasource.password
=
qiyang@2013
log.datasource.url
=
jdbc:mysql://10.10.0.21:3306/shopLog?useSSL=false&useUnicode=true&characterEncoding=utf8
...
...
@@ -68,3 +69,5 @@ spring.redis.pool.min-idle=0
redis.guest.key
=
B2B_Guest
#### 用户验证码存储的前缀
redis.sms.code.key
=
B2B_Sms
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