Commit c452a235 authored by Quxl's avatar Quxl

x

parent 9eeec08f
......@@ -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", "ORDER");
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", "ORDER");
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();
}
}
}
......
......@@ -25,6 +25,7 @@ spring.datasource.validationQueryTimeout=5
spring.datasource.validationQuery=SELECT 1
spring.datasource.timeBetweenEvictionRunsMillis=3600000
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
......
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