Commit 41a5111d authored by Quxl's avatar Quxl

x

parent aa9e7acb
......@@ -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
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();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment