|
@@ -41,7 +41,7 @@ public class AuditLogInterceptor extends HandlerInterceptorAdapter {
|
|
|
|
|
|
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
- private static List<String> logUrl;
|
|
|
+ private static List<String> ignoreLogUrl;
|
|
|
|
|
|
|
|
|
|
|
@@ -52,37 +52,45 @@ public class AuditLogInterceptor extends HandlerInterceptorAdapter {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
|
|
- String servletPath = request.getServletPath();
|
|
|
- HandlerMethod handlerMethod = (HandlerMethod) handler;
|
|
|
- AuditLogAnnotation anno = handlerMethod.getMethodAnnotation(AuditLogAnnotation.class);
|
|
|
- ApiOperation apiOperation = handlerMethod.getMethodAnnotation(ApiOperation.class);
|
|
|
- String operateName = null;
|
|
|
- if(StringUtils.isEmpty(operateName) && apiOperation != null){
|
|
|
- operateName = apiOperation.value();
|
|
|
- }
|
|
|
- if(StringUtils.isEmpty(operateName) && anno != null){
|
|
|
- operateName = anno.operateName();
|
|
|
- }
|
|
|
- if(anno != null){
|
|
|
- saveLog(operateName,servletPath,request);
|
|
|
- return;
|
|
|
- }
|
|
|
- if(servletPath.contains("/task/")){
|
|
|
- return;
|
|
|
- }
|
|
|
- String substring = servletPath.substring(servletPath.lastIndexOf("/") + 1).toLowerCase();
|
|
|
- if(logUrl == null){
|
|
|
- logUrl = new ArrayList<>();
|
|
|
- logUrl.add("update");
|
|
|
- logUrl.add("modify");
|
|
|
- logUrl.add("del");
|
|
|
- }
|
|
|
- for (String e : logUrl) {
|
|
|
- if(substring.contains(e)){
|
|
|
+ public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
|
|
|
+ try {
|
|
|
+ String servletPath = request.getServletPath();
|
|
|
+ HandlerMethod handlerMethod = (HandlerMethod) handler;
|
|
|
+ AuditLogAnnotation anno = handlerMethod.getMethodAnnotation(AuditLogAnnotation.class);
|
|
|
+ ApiOperation apiOperation = handlerMethod.getMethodAnnotation(ApiOperation.class);
|
|
|
+ String operateName = null;
|
|
|
+ if(StringUtils.isEmpty(operateName) && apiOperation != null){
|
|
|
+ operateName = apiOperation.value();
|
|
|
+ }
|
|
|
+ if(StringUtils.isEmpty(operateName) && anno != null){
|
|
|
+ operateName = anno.operateName();
|
|
|
+ }
|
|
|
+ if(anno != null){
|
|
|
saveLog(operateName,servletPath,request);
|
|
|
- break;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(servletPath.contains("/task/") || servletPath.contains("/import/") ){
|
|
|
+ return;
|
|
|
}
|
|
|
+ String substring = servletPath.substring(servletPath.lastIndexOf("/") + 1).toLowerCase();
|
|
|
+ if(ignoreLogUrl == null){
|
|
|
+ ignoreLogUrl = new ArrayList<>();
|
|
|
+ ignoreLogUrl.add("add");
|
|
|
+ ignoreLogUrl.add("insert");
|
|
|
+ ignoreLogUrl.add("query");
|
|
|
+ ignoreLogUrl.add("get");
|
|
|
+ ignoreLogUrl.add("find");
|
|
|
+ ignoreLogUrl.add("list");
|
|
|
+ ignoreLogUrl.add("detail");
|
|
|
+ }
|
|
|
+ for (String e : ignoreLogUrl) {
|
|
|
+ if(substring.contains(e)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ saveLog(operateName,servletPath,request);
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|