添加查看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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user