Joburgess 4 years ago
parent
commit
58fd6c70f3

+ 5 - 0
mec-common/audit-log/src/main/java/com/yonge/log/interceptor/AuditLogInterceptor.java

@@ -15,6 +15,8 @@ import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
 import org.springframework.web.method.HandlerMethod;
 import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
 
@@ -60,6 +62,9 @@ public class AuditLogInterceptor extends HandlerInterceptorAdapter {
 				auditLog.setInterfaceUrl(request.getRequestURI());
 			}
 			auditLog.setToken(request.getHeader("Authorization"));
+			WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(request.getServletContext());
+
+			String applicationName = webApplicationContext.getId();
 			auditLog.setUserIp(WebUtil.getRemoteIp(request));
 
 			Map<String, Object> params = WebUtil.getParameterMap(request);