1:新增请求地址字段

2:修改访问swagger日志界面和行为日志界面时不记录日志
This commit is contained in:
RenKaiGe-Office
2018-08-08 14:29:43 +08:00
parent 35709dedbf
commit 1a729ee973
4 changed files with 66 additions and 25 deletions

View File

@@ -3,7 +3,7 @@ package com.nis.domain;
import java.util.Date;
public class SwaggerLog extends BaseEntity<SwaggerLog> {
private static final long serialVersionUID = 5351369774420087482L;
private static final long serialVersionUID = 1L;
private String operator;
private String version;
private Integer opAction;
@@ -16,13 +16,13 @@ public class SwaggerLog extends BaseEntity<SwaggerLog> {
private String exceptionInfo;
private String serverIp;
private String traceCode;
private String requestUri;
private String exception;// 界面的异常信息框
private Date beginDate; // 开始日期
private Date endDate; // 结束日期
public String getOperator() {
return operator;
}
@@ -143,4 +143,12 @@ public class SwaggerLog extends BaseEntity<SwaggerLog> {
this.endDate = endDate;
}
public String getRequestUri() {
return requestUri;
}
public void setRequestUri(String requestUri) {
this.requestUri = requestUri;
}
}

View File

@@ -88,8 +88,8 @@ public class LogInterceptor extends BaseService implements HandlerInterceptor {
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
String requestURI = request.getRequestURI();
// logger.info("请求路径是:" + requestURI);
// logger.info("请求参数是:" + getBodyString(request));
// logger.info("请求路径是:" + requestURI);
// logger.info("请求参数是:" + getBodyString(request));
long beginTime = System.currentTimeMillis();// 1、开始时间
timeThreadLocal.set(beginTime); // 线程绑定变量(该数据只有当前请求的线程可见)
if (logger.isDebugEnabled()) {
@@ -128,9 +128,13 @@ public class LogInterceptor extends BaseService implements HandlerInterceptor {
}
// 保存日志
LogUtils.saveLog(request, handler, ex, null, consumerTime);
String requestURI = request.getRequestURI();
// swagger日志请求和行为日志请求不记录请求日志
if (!requestURI.equals("/galaxy/nis/sys/log/swaggerLogList")
&& !requestURI.equals("/galaxy/nis/sys/log/list")) {
// 保存日志
LogUtils.saveLog(request, handler, ex, null, consumerTime);
}
}
}

View File

@@ -18,6 +18,15 @@
<if test="traceCode != null and traceCode != ''">
AND a.trace_Code=#{traceCode}
</if>
<if test="businessCode != null and businessCode != ''">
AND a.business_Code=#{businessCode}
</if>
<if test="requestUri != null and requestUri != ''">
AND a.REQUEST_URI LIKE
<if test="dbName == 'oracle'">'%'||#{requestUri}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{requestUri}+'%'</if>
<if test="dbName == 'mysql'">CONCAT('%', #{requestUri}, '%')</if>
</if>
<if test="exceptionInfo != null and exceptionInfo != ''">
AND a.exception_Info LIKE

View File

@@ -5,7 +5,8 @@
<title>swagger日志管理</title>
<script type="text/javascript">
$(document).ready(function(){
$(".tooltips").tooltip();
// $(".tooltips").tooltip();
$("[data-toggle='popover']").popover();
});
function page(n,s){
$("#pageNo").val(n);
@@ -19,19 +20,30 @@
<!-- <ul class="nav nav-tabs"> -->
<%-- <li class="active"><a href="${ctx}/sys/log/">日志列表</a></li> --%>
<!-- </ul> -->
<form:form id="searchForm" action="${ctx}/sys/log/swaggerLogList" method="post" class="breadcrumb form-search">
<form:form modelAttribute="swaggerLog" id="searchForm" action="${ctx}/sys/log/swaggerLogList" method="post" class="breadcrumb form-search">
<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
<div>
<label>操作行为:</label>
<select name="opAction" class="input-medium">
<option value="" selected="selected">请选择</option>
<option value="1">插入</option>
<option value="2">更新</option>
<option value="3">删除</option>
<option value="4">查询</option>
</select>
<label>traceCode</label><input id="traceCode" name="traceCode" type="text" maxlength="30" class="input-mini" value="${swaggerLog.traceCode}"/>
<!-- <select name="opAction" class="input-medium"> -->
<!-- <option value="" selected="selected">请选择</option> -->
<!-- <option value="1">插入</option> -->
<!-- <option value="2">更新</option> -->
<!-- <option value="3">删除</option> -->
<!-- <option value="4">查询</option> -->
<!-- </select> -->
<form:select path="opAction" class="input-medium">
<form:option value="">请选择</form:option>
<form:option value="1">插入</form:option>
<form:option value="2">更新</form:option>
<form:option value="3">删除</form:option>
<form:option value="4">查询</form:option>
</form:select>
<label>TRACECODE</label><input id="traceCode" name="traceCode" type="text" maxlength="30" class="input-mini" value="${swaggerLog.traceCode}"/>
<label>BUSINESSCODE</label><input id="businessCode" name="businessCode" type="text" maxlength="30" class="input-mini" value="${swaggerLog.businessCode}"/>
<label>异常信息:</label><input id="exceptionInfo" name="exceptionInfo" type="text" maxlength="500" class="input-mini" value="${swaggerLog.exceptionInfo}"/>
<label>请求ip</label><input id="requestIp" name="requestIp" type="text" maxlength="50" class="input-mini" value="${swaggerLog.requestIp}"/>
<label>服务端ip</label><input id="serverIp" name="serverIp" type="text" maxlength="50" class="input-mini" value="${swaggerLog.serverIp}"/>
@@ -49,15 +61,23 @@
</form:form>
<sys:message content="${message}"/>
<table id="contentTable" class="table table-striped table-bordered table-condensed">
<thead><tr><th>请求内容</th><th>traceCode</th><th>操作行为</th><th>请求ip</th><th>服务端ip</th><th>请求时间</th></thead>
<thead><tr><th>请求地址</th><th>请求内容</th><th>TRACECODE</th><th>BUSINESSCODE</th><th>操作行为</th><th>请求ip</th><th>服务端ip</th><th>请求时间</th></thead>
<tbody><%request.setAttribute("strEnter", "\n");request.setAttribute("strTab", "\t");%>
<c:forEach items="${page.list}" var="swaggerLog">
<tr>
<td>${swaggerLog.requestUri}</td>
<td>
<a data-original-title="${fn:escapeXml(swaggerLog.requestContent) }" class="tooltips" data-flag="false"
data-html="true" data-placement="top"> ${fn:substring(swaggerLog.requestContent,0,20) }</a>
<%-- <a data-original-title="${fn:escapeXml(swaggerLog.requestContent) }" class="tooltips" data-flag="false" --%>
<%-- data-placement="bottom"> ${fn:substring(swaggerLog.requestContent,0,20) }</a> --%>
<%-- <a title="${fn:escapeXml(swaggerLog.requestContent) }" class="tooltips" data-toggle="tooltip" --%>
<%-- data-placement="top"> ${fn:substring(swaggerLog.requestContent,0,20) }</a> --%>
<a title="${fn:escapeXml(swaggerLog.requestContent) }" data-container="body" data-toggle="popover"
data-placement="bottom"> ${fn:substring(swaggerLog.requestContent,0,20) }</a>
</td>
<td>${swaggerLog.traceCode}</td>
<td>${swaggerLog.businessCode}</td>
<td>
<c:if test="${swaggerLog.opAction eq 1}">插入</c:if>
<c:if test="${swaggerLog.opAction eq 2}">更新</c:if>
@@ -67,7 +87,7 @@
</td>
<td><strong>${swaggerLog.requestIp}</strong></td>
<td>${swaggerLog.serverIp}</td>
<td><fmt:formatDate value="${swaggerLog.requestTime}" type="both"/></td>
<td><fmt:formatDate value="${swaggerLog.requestTime}" type="both" pattern="yyyy-MM-dd HH:mm:ss"/></td>
</tr>
<c:if test="${not empty swaggerLog.exceptionInfo}"><tr>
<td colspan="8" style="word-wrap:break-word;word-break:break-all;">