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
41a5111d
Commit
41a5111d
authored
Oct 15, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
aa9e7acb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
7 deletions
+19
-7
DataSourceConfig.java
src/main/java/com/egolm/shop/config/DataSourceConfig.java
+1
-3
CommonInterceptor.java
.../com/egolm/shop/config/interceptor/CommonInterceptor.java
+18
-4
No files found.
src/main/java/com/egolm/shop/config/DataSourceConfig.java
View file @
41a5111d
...
...
@@ -59,9 +59,6 @@ public class DataSourceConfig {
return
wallConfig
;
}
@Bean
@Qualifier
(
"log"
)
@ConfigurationProperties
(
prefix
=
"log.datasource"
)
...
...
@@ -78,4 +75,5 @@ public class DataSourceConfig {
jdbcTemplate
.
setSql_level
(
3
);
return
jdbcTemplate
;
}
}
\ No newline at end of file
src/main/java/com/egolm/shop/config/interceptor/CommonInterceptor.java
View file @
41a5111d
package
com
.
egolm
.
shop
.
config
.
interceptor
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.servlet.handler.HandlerInterceptorAdapter
;
import
com.alibaba.fastjson.JSON
;
import
com.egolm.common.jdbc.JdbcTemplate
;
import
com.egolm.common.web.ServletUtil
;
@Component
...
...
@@ -19,6 +26,10 @@ public class CommonInterceptor extends HandlerInterceptorAdapter {
return
super
.
preHandle
(
req
,
resp
,
handler
);
}
@Autowired
@Qualifier
(
"log"
)
private
JdbcTemplate
jdbcTemplate
;
@Async
private
void
exec
(
HttpServletRequest
req
)
{
try
{
...
...
@@ -26,10 +37,13 @@ public class CommonInterceptor extends HandlerInterceptorAdapter {
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
();
}
...
...
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