添加查看swagger日志的界面
This commit is contained in:
154
src/main/java/com/nis/domain/SwaggerLog.java
Normal file
154
src/main/java/com/nis/domain/SwaggerLog.java
Normal file
@@ -0,0 +1,154 @@
|
||||
package com.nis.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class SwaggerLog extends BaseEntity<SwaggerLog> {
|
||||
private static final long serialVersionUID = 5351369774420087482L;
|
||||
private Long id;
|
||||
private String operator;
|
||||
private String version;
|
||||
private Integer opAction;
|
||||
private Date opTime;
|
||||
private String requestContent;
|
||||
private Date requestTime;
|
||||
private Long consumerTime;
|
||||
private String requestIp;
|
||||
private Integer businessCode;
|
||||
private String exceptionInfo;
|
||||
private String serverIp;
|
||||
private String traceCode;
|
||||
|
||||
private String exception;// 界面的异常信息框
|
||||
|
||||
private Date beginDate; // 开始日期
|
||||
private Date endDate; // 结束日期
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
public void setOperator(String operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public Integer getOpAction() {
|
||||
return opAction;
|
||||
}
|
||||
|
||||
public void setOpAction(Integer opAction) {
|
||||
this.opAction = opAction;
|
||||
}
|
||||
|
||||
public Date getOpTime() {
|
||||
return opTime;
|
||||
}
|
||||
|
||||
public void setOpTime(Date opTime) {
|
||||
this.opTime = opTime;
|
||||
}
|
||||
|
||||
public String getRequestContent() {
|
||||
return requestContent;
|
||||
}
|
||||
|
||||
public void setRequestContent(String requestContent) {
|
||||
this.requestContent = requestContent;
|
||||
}
|
||||
|
||||
public Date getRequestTime() {
|
||||
return requestTime;
|
||||
}
|
||||
|
||||
public void setRequestTime(Date requestTime) {
|
||||
this.requestTime = requestTime;
|
||||
}
|
||||
|
||||
public Long getConsumerTime() {
|
||||
return consumerTime;
|
||||
}
|
||||
|
||||
public void setConsumerTime(Long consumerTime) {
|
||||
this.consumerTime = consumerTime;
|
||||
}
|
||||
|
||||
public String getRequestIp() {
|
||||
return requestIp;
|
||||
}
|
||||
|
||||
public void setRequestIp(String requestIp) {
|
||||
this.requestIp = requestIp;
|
||||
}
|
||||
|
||||
public Integer getBusinessCode() {
|
||||
return businessCode;
|
||||
}
|
||||
|
||||
public void setBusinessCode(Integer businessCode) {
|
||||
this.businessCode = businessCode;
|
||||
}
|
||||
|
||||
public String getExceptionInfo() {
|
||||
return exceptionInfo;
|
||||
}
|
||||
|
||||
public void setExceptionInfo(String exceptionInfo) {
|
||||
this.exceptionInfo = exceptionInfo;
|
||||
}
|
||||
|
||||
public String getServerIp() {
|
||||
return serverIp;
|
||||
}
|
||||
|
||||
public void setServerIp(String serverIp) {
|
||||
this.serverIp = serverIp;
|
||||
}
|
||||
|
||||
public String getTraceCode() {
|
||||
return traceCode;
|
||||
}
|
||||
|
||||
public void setTraceCode(String traceCode) {
|
||||
this.traceCode = traceCode;
|
||||
}
|
||||
|
||||
public String getException() {
|
||||
return exception;
|
||||
}
|
||||
|
||||
public void setException(String exception) {
|
||||
this.exception = exception;
|
||||
}
|
||||
|
||||
public Date getBeginDate() {
|
||||
return beginDate;
|
||||
}
|
||||
|
||||
public void setBeginDate(Date beginDate) {
|
||||
this.beginDate = beginDate;
|
||||
}
|
||||
|
||||
public Date getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(Date endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -153,7 +153,7 @@ public class SQLHelper {
|
||||
*/
|
||||
public static Long getCount(final String sql, final Connection connection, final MappedStatement mappedStatement,
|
||||
final Object parameterObject, final BoundSql boundSql, Log log) throws SQLException {
|
||||
logger.info("count查询开始----"+System.currentTimeMillis());
|
||||
logger.info("开始count查询----"+System.currentTimeMillis());
|
||||
String dbName = getDBType();
|
||||
final String countSql;
|
||||
if ("oracle".equals(dbName)) {
|
||||
@@ -194,7 +194,7 @@ public class SQLHelper {
|
||||
}
|
||||
return count;
|
||||
} finally {
|
||||
logger.info("oracle查询count结束----"+System.currentTimeMillis());
|
||||
logger.info("count查询结束----"+System.currentTimeMillis());
|
||||
if (rs != null) {
|
||||
rs.close();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.nis.web.service.LogService;
|
||||
import com.nis.web.service.MenuService;
|
||||
import com.nis.web.service.OfficeService;
|
||||
import com.nis.web.service.RoleService;
|
||||
import com.nis.web.service.SwaggerLogService;
|
||||
import com.nis.web.service.SystemService;
|
||||
import com.nis.web.service.UserService;
|
||||
|
||||
@@ -50,6 +51,9 @@ public class BaseController {
|
||||
@Autowired
|
||||
protected LogService logService;
|
||||
|
||||
@Autowired
|
||||
protected SwaggerLogService swaggerLogService;
|
||||
|
||||
@Autowired
|
||||
protected ArchiveServcie archiveServcie;
|
||||
|
||||
|
||||
@@ -9,19 +9,28 @@ import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.SwaggerLog;
|
||||
import com.nis.domain.SysLog;
|
||||
import com.nis.web.controller.BaseController;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("${adminPath}/sys/log")
|
||||
public class SysLogController extends BaseController {
|
||||
|
||||
|
||||
@RequiresPermissions("sys:log:view")
|
||||
@RequestMapping(value = {"list", ""})
|
||||
@RequestMapping(value = "list")
|
||||
public String list(SysLog sysLog, HttpServletRequest request, HttpServletResponse response, Model model) {
|
||||
Page<SysLog> page = logService.findPage(new Page<SysLog>(request, response), sysLog);
|
||||
model.addAttribute("page", page);
|
||||
Page<SysLog> page = logService.findPage(new Page<SysLog>(request, response), sysLog);
|
||||
model.addAttribute("page", page);
|
||||
return "/sys/logList";
|
||||
}
|
||||
|
||||
@RequiresPermissions("sys:swaggerLogList:view")
|
||||
@RequestMapping(value = "swaggerLogList")
|
||||
public String swaggerLogList(SwaggerLog sysLog, HttpServletRequest request, HttpServletResponse response, Model model) {
|
||||
Page<SwaggerLog> page = swaggerLogService.findSwaggerLogPage(new Page<SwaggerLog>(request, response), sysLog);
|
||||
model.addAttribute("page", page);
|
||||
return "/sys/swaggerLogList";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
7
src/main/java/com/nis/web/dao/SwaggerLogDao.java
Normal file
7
src/main/java/com/nis/web/dao/SwaggerLogDao.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package com.nis.web.dao;
|
||||
|
||||
import com.nis.domain.SwaggerLog;
|
||||
@MyBatisDao
|
||||
public interface SwaggerLogDao extends CrudDao<SwaggerLog>{
|
||||
|
||||
}
|
||||
46
src/main/java/com/nis/web/dao/SwaggerLogDao.xml
Normal file
46
src/main/java/com/nis/web/dao/SwaggerLogDao.xml
Normal file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.nis.web.dao.SwaggerLogDao">
|
||||
|
||||
<select id="findList" resultType="swaggerLog">
|
||||
SELECT
|
||||
a.*
|
||||
FROM services_request_log a
|
||||
WHERE a.request_time BETWEEN
|
||||
#{beginDate} AND #{endDate}
|
||||
|
||||
<if test="requestContent != null and requestContent != ''">
|
||||
AND a.request_Content LIKE
|
||||
<if test="dbName == 'oracle'">'%'||#{requestContent}||'%'</if>
|
||||
<if test="dbName == 'mssql'">'%'+#{requestContent}+'%'</if>
|
||||
<if test="dbName == 'mysql'">CONCAT('%', #{requestContent}, '%')</if>
|
||||
</if>
|
||||
|
||||
<if test="exceptionInfo != null and exceptionInfo != ''">
|
||||
AND a.exception_Info LIKE
|
||||
<if test="dbName == 'oracle'">'%'||#{exceptionInfo}||'%'</if>
|
||||
<if test="dbName == 'mssql'">'%'+#{exceptionInfo}+'%'</if>
|
||||
<if test="dbName == 'mysql'">CONCAT('%', #{exceptionInfo}, '%')</if>
|
||||
</if>
|
||||
|
||||
<if test="requestIp != null and requestIp != ''">
|
||||
AND a.request_ip like
|
||||
<if test="dbName == 'oracle'">'%'||#{requestIp}||'%'</if>
|
||||
<if test="dbName == 'mssql'">'%'+#{requestIp}+'%'</if>
|
||||
<if test="dbName == 'mysql'">CONCAT('%', #{requestIp}, '%')</if>
|
||||
</if>
|
||||
<if test="serverIp != null and serverIp != ''">
|
||||
AND a.server_Ip like
|
||||
<if test="dbName == 'oracle'">'%'||#{serverIp}||'%'</if>
|
||||
<if test="dbName == 'mssql'">'%'+#{serverIp}+'%'</if>
|
||||
<if test="dbName == 'mysql'">CONCAT('%', #{serverIp}, '%')</if>
|
||||
</if>
|
||||
<if test="exception != null and exception != ''">
|
||||
AND a.exception_Info!=''
|
||||
</if>
|
||||
ORDER BY a.request_time DESC
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
25
src/main/java/com/nis/web/service/SwaggerLogService.java
Normal file
25
src/main/java/com/nis/web/service/SwaggerLogService.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.nis.web.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.SwaggerLog;
|
||||
import com.nis.util.DateUtils;
|
||||
import com.nis.web.dao.SwaggerLogDao;
|
||||
|
||||
@Service
|
||||
public class SwaggerLogService extends CrudService<SwaggerLogDao, SwaggerLog> {
|
||||
|
||||
|
||||
public Page<SwaggerLog> findSwaggerLogPage(Page<SwaggerLog> page, SwaggerLog sysLog) {
|
||||
// 设置默认时间范围,默认当前月
|
||||
if (sysLog.getBeginDate() == null) {
|
||||
sysLog.setBeginDate(DateUtils.setDays(DateUtils.parseDate(DateUtils.getDate()), 1));
|
||||
}
|
||||
if (sysLog.getEndDate() == null) {
|
||||
sysLog.setEndDate(DateUtils.addMonths(sysLog.getBeginDate(), 1));
|
||||
}
|
||||
return super.findPage(page, sysLog);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
<!-- <ul class="nav nav-tabs"> -->
|
||||
<%-- <li class="active"><a href="${ctx}/sys/log/">日志列表</a></li> --%>
|
||||
<!-- </ul> -->
|
||||
<form:form id="searchForm" action="${ctx}/sys/log" method="post" class="breadcrumb form-search">
|
||||
<form:form id="searchForm" action="${ctx}/sys/log/list" 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>
|
||||
|
||||
67
src/main/webapp/WEB-INF/views/sys/swaggerLogList.jsp
Normal file
67
src/main/webapp/WEB-INF/views/sys/swaggerLogList.jsp
Normal file
@@ -0,0 +1,67 @@
|
||||
<%@ page contentType="text/html;charset=UTF-8" %>
|
||||
<%@ include file="/WEB-INF/include/taglib.jsp"%>
|
||||
<html>
|
||||
<head>
|
||||
<title>swagger日志管理</title>
|
||||
<script type="text/javascript">
|
||||
function page(n,s){
|
||||
$("#pageNo").val(n);
|
||||
$("#pageSize").val(s);
|
||||
$("#searchForm").submit();
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<!-- <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">
|
||||
<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
|
||||
<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
|
||||
<div>
|
||||
<label>请求内容:</label><input id="requestContent" name="requestContent" type="text" maxlength="500" class="input-mini" value="${swaggerLog.requestContent}"/>
|
||||
<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}"/>
|
||||
</div><div style="margin-top:8px;">
|
||||
<label>请求日期范围: </label><input id="beginDate" name="beginDate" type="text" readonly="readonly" maxlength="20" class="input-mini Wdate"
|
||||
value="<fmt:formatDate value="${swaggerLog.beginDate}" pattern="yyyy-MM-dd"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
|
||||
<label> -- </label><input id="endDate" name="endDate" type="text" readonly="readonly" maxlength="20" class="input-mini Wdate"
|
||||
value="<fmt:formatDate value="${swaggerLog.endDate}" pattern="yyyy-MM-dd"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
|
||||
<label for="exception">
|
||||
|
||||
<input id="exception" name="exception" type="checkbox"${swaggerLog.exception eq '1'?' checked':''} value="1"/>只查询异常信息</label>
|
||||
|
||||
<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
|
||||
</div>
|
||||
</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>
|
||||
<tbody><%request.setAttribute("strEnter", "\n");request.setAttribute("strTab", "\t");%>
|
||||
<c:forEach items="${page.list}" var="log">
|
||||
<tr>
|
||||
<td>
|
||||
<a data-original-title="${log.requestContent }" class="tooltips" data-flag="false"
|
||||
data-html="true" data-placement="top"> ${fn:substring(log.requestContent,0,20) }</a>
|
||||
</td>
|
||||
<td>${log.traceCode}</td>
|
||||
<td>${log.opAction}</td>
|
||||
<td><strong>${log.requestIp}</strong></td>
|
||||
<td>${log.serverIp}</td>
|
||||
<td><fmt:formatDate value="${log.requestTime}" type="both"/></td>
|
||||
</tr>
|
||||
<c:if test="${not empty log.exceptionInfo}"><tr>
|
||||
<td colspan="8" style="word-wrap:break-word;word-break:break-all;">
|
||||
<%-- 用户代理: ${log.userAgent}<br/> --%>
|
||||
<%-- 提交参数: ${fns:escapeHtml(log.params)} <br/> --%>
|
||||
异常信息: <br/>
|
||||
${fn:replace(fn:replace(fns:escapeHtml(log.exceptionInfo), strEnter, '<br/>'), strTab, ' ')}</td>
|
||||
</tr></c:if>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="pagination">${page}</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -77,6 +77,12 @@
|
||||
<listener>
|
||||
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
|
||||
</listener>
|
||||
<!-- 让web应用程序启动那个时自动添加属性文件 -->
|
||||
<context-param>
|
||||
<param-name>log4jConfigLocation</param-name>
|
||||
<param-value>classpath:log4j.properties</param-value>
|
||||
</context-param>
|
||||
|
||||
<context-param>
|
||||
<param-name>webAppRootKey</param-name>
|
||||
<param-value>nis.root</param-value>
|
||||
|
||||
Reference in New Issue
Block a user