From 5bc6bc9e6b9a3a650af9f628ae28e980eea2f888 Mon Sep 17 00:00:00 2001 From: thinkgem Date: Wed, 17 Jan 2018 23:26:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=9F=A5=E8=AF=A2=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E6=9A=82=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/interceptor/LogInterceptorConfig.java | 2 +- .../MobileViewInterceptorConfig.java | 2 +- .../modules/sys/service/LogService.java | 122 ++++++----- .../jeesite/modules/sys/utils/LogUtils.java | 2 +- .../core/src/main/resources/jeesite-core.yml | 6 +- .../resources/views/modules/sys/logForm.html | 195 ++++++++++++++++++ .../resources/views/modules/sys/logList.html | 151 ++++++++++++++ 7 files changed, 411 insertions(+), 69 deletions(-) create mode 100644 modules/core/src/main/resources/views/modules/sys/logForm.html create mode 100644 modules/core/src/main/resources/views/modules/sys/logList.html diff --git a/modules/core/src/main/java/com/jeesite/modules/config/web/interceptor/LogInterceptorConfig.java b/modules/core/src/main/java/com/jeesite/modules/config/web/interceptor/LogInterceptorConfig.java index b83324b8..8606adf0 100644 --- a/modules/core/src/main/java/com/jeesite/modules/config/web/interceptor/LogInterceptorConfig.java +++ b/modules/core/src/main/java/com/jeesite/modules/config/web/interceptor/LogInterceptorConfig.java @@ -36,7 +36,7 @@ public class LogInterceptorConfig extends WebMvcConfigurerAdapter { } for (String uri : StringUtils.split(epps, ",")){ if (StringUtils.isNotBlank(uri)){ - registration.excludePathPatterns(StringUtils.trim(epps)); + registration.excludePathPatterns(StringUtils.trim(uri)); } } } diff --git a/modules/core/src/main/java/com/jeesite/modules/config/web/interceptor/MobileViewInterceptorConfig.java b/modules/core/src/main/java/com/jeesite/modules/config/web/interceptor/MobileViewInterceptorConfig.java index c16b02cc..d78d6599 100644 --- a/modules/core/src/main/java/com/jeesite/modules/config/web/interceptor/MobileViewInterceptorConfig.java +++ b/modules/core/src/main/java/com/jeesite/modules/config/web/interceptor/MobileViewInterceptorConfig.java @@ -36,7 +36,7 @@ public class MobileViewInterceptorConfig extends WebMvcConfigurerAdapter { } for (String uri : StringUtils.split(epps, ",")){ if (StringUtils.isNotBlank(uri)){ - registration.excludePathPatterns(StringUtils.trim(epps)); + registration.excludePathPatterns(StringUtils.trim(uri)); } } } diff --git a/modules/core/src/main/java/com/jeesite/modules/sys/service/LogService.java b/modules/core/src/main/java/com/jeesite/modules/sys/service/LogService.java index baa59874..172f0a8b 100644 --- a/modules/core/src/main/java/com/jeesite/modules/sys/service/LogService.java +++ b/modules/core/src/main/java/com/jeesite/modules/sys/service/LogService.java @@ -1,63 +1,59 @@ -/** - * Copyright (c) 2013-Now http://jeesite.com All rights reserved. - */ -package com.jeesite.modules.sys.service; - -import java.util.Date; - -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; - -import com.jeesite.common.entity.Page; -import com.jeesite.common.lang.DateUtils; -import com.jeesite.common.service.CrudService; -import com.jeesite.modules.sys.dao.LogDao; -import com.jeesite.modules.sys.entity.Log; -import com.jeesite.modules.sys.entity.User; - -/** - * 日志Service - * @author ThinkGem - * @version 2014-05-16 - */ -@Service -@Transactional(readOnly=true) -public class LogService extends CrudService { - - /** - * 查询日志记录 - */ - @Override - public Page findPage(Page page, Log log) { - - // 设置默认时间范围,默认当前月 - if (log.getCreateDate_gte() == null){ - log.setCreateDate_gte(DateUtils.setDays(new Date(), 1)); - } - if (log.getCreateDate_lte() == null){ - log.setCreateDate_lte(DateUtils.addDays(DateUtils.addMonths(log.getCreateDate_gte(), 1), -1)); - } - - // 为了方便进行按天查询,设置一天的开始和结束时间(如:开始为一天的0点0分,结束为一天的23点59分) - log.setCreateDate_gte(DateUtils.getOfDayFirst(log.getCreateDate_gte())); - log.setCreateDate_lte(DateUtils.getOfDayLast(log.getCreateDate_lte())); - - // 普通用户看自己的,管理员看全部的。 - if (!log.getCurrentUser().isAdmin()){ - log.setCreateBy(new User(log.getCurrentUser().getUserCode())); - } - - return super.findPage(page, log); - - } - - /** - * 不使用数据库事务,执行插入日志 - */ - @Transactional(readOnly=false, propagation=Propagation.NOT_SUPPORTED) - public void insertLog(Log entity) { - dao.insert(entity); - } - -} +/** + * Copyright (c) 2013-Now http://jeesite.com All rights reserved. + */ +package com.jeesite.modules.sys.service; + +import java.util.Date; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import com.jeesite.common.entity.Page; +import com.jeesite.common.lang.DateUtils; +import com.jeesite.common.service.CrudService; +import com.jeesite.modules.sys.dao.LogDao; +import com.jeesite.modules.sys.entity.Log; +import com.jeesite.modules.sys.entity.User; + +/** + * 日志Service + * @author ThinkGem + * @version 2014-05-16 + */ +@Service +@Transactional(readOnly=true) +public class LogService extends CrudService { + + /** + * 查询日志记录 + */ + @Override + public Page findPage(Page page, Log log) { + + // 设置默认时间范围,默认当前月 + if (log.getCreateDate_gte() == null){ + log.setCreateDate_gte(DateUtils.setDays(new Date(), 1)); + } + if (log.getCreateDate_lte() == null){ + log.setCreateDate_lte(DateUtils.addDays(DateUtils.addMonths(log.getCreateDate_gte(), 1), -1)); + } + + // 普通用户看自己的,管理员看全部的。 + if (!log.getCurrentUser().isAdmin()){ + log.setCreateBy(new User(log.getCurrentUser().getUserCode())); + } + + return super.findPage(page, log); + + } + + /** + * 不使用数据库事务,执行插入日志 + */ + @Transactional(readOnly=false, propagation=Propagation.NOT_SUPPORTED) + public void insertLog(Log entity) { + dao.insert(entity); + } + +} diff --git a/modules/core/src/main/java/com/jeesite/modules/sys/utils/LogUtils.java b/modules/core/src/main/java/com/jeesite/modules/sys/utils/LogUtils.java index 5478d285..7b605352 100644 --- a/modules/core/src/main/java/com/jeesite/modules/sys/utils/LogUtils.java +++ b/modules/core/src/main/java/com/jeesite/modules/sys/utils/LogUtils.java @@ -181,7 +181,7 @@ public class LogUtils { log.setLogTitle("未知操作"); } // 如果有异常,设置异常信息(将异常对象转换为字符串) - log.setExceptionInfo(throwable != null ? Global.YES : Global.NO); + log.setIsException(throwable != null ? Global.YES : Global.NO); log.setExceptionInfo(ExceptionUtils.getStackTraceAsString(throwable)); // 如果无地址并无异常日志,则不保存信息 if (StringUtils.isBlank(log.getRequestUri()) && StringUtils.isBlank(log.getExceptionInfo())){ diff --git a/modules/core/src/main/resources/jeesite-core.yml b/modules/core/src/main/resources/jeesite-core.yml index 7270746a..d2f9427d 100644 --- a/modules/core/src/main/resources/jeesite-core.yml +++ b/modules/core/src/main/resources/jeesite-core.yml @@ -365,12 +365,12 @@ web: excludePathPatterns: > ${adminPath}/index, ${adminPath}/login, + ${adminPath}/desktop, + ${adminPath}/sys/online/count, ${adminPath}/**/listData, ${adminPath}/**/treeData, ${adminPath}/file/**, - ${adminPath}/tags/*, - ${adminPath}/sys/log/**, - ${adminPath}/sys/online/count + ${adminPath}/tags/* # 前台自动切换到手机视图拦截器 mobile: diff --git a/modules/core/src/main/resources/views/modules/sys/logForm.html b/modules/core/src/main/resources/views/modules/sys/logForm.html new file mode 100644 index 00000000..a28ea7e6 --- /dev/null +++ b/modules/core/src/main/resources/views/modules/sys/logForm.html @@ -0,0 +1,195 @@ +<% layout('/layouts/default.html', {title: '操作日志表管理', libs: ['validate']}){ %> +
+
+
+
+ ${log.isNewRecord ? '新增操作日志表' : '编辑操作日志表'} +
+
+ +
+
+ <#form:form id="inputForm" model="${log}" action="${ctx}/sys/log/save" method="post" class="form-horizontal"> +
+
基本信息
+ <#form:hidden path="id"/> +
+
+
+ +
+ <#form:input path="logTitle" maxlength="500" class="form-control required "/> +
+
+
+
+
+ +
+ <#form:select path="logType" dictType="sys_log_type" class="form-control required " /> +
+
+
+
+
+
+
+ +
+ <#form:input path="createByName" maxlength="100" class="form-control required "/> +
+
+
+
+
+ +
+ <#form:input path="requestUri" maxlength="255" class="form-control "/> +
+
+
+
+
+
+
+ +
+ <#form:input path="requestMethod" maxlength="10" class="form-control "/> +
+
+
+
+
+ +
+ <#form:input path="requestParams" class="form-control "/> +
+
+
+
+
+
+
+ +
+ <#form:input path="bizKey" maxlength="64" class="form-control "/> +
+
+
+
+
+ +
+ <#form:input path="bizType" maxlength="64" class="form-control "/> +
+
+
+
+
+
+
+ +
+ <#form:input path="remoteAddr" maxlength="255" class="form-control required "/> +
+
+
+
+
+ +
+ <#form:input path="serverAddr" maxlength="255" class="form-control required "/> +
+
+
+
+
+
+
+ +
+ <#form:select path="isException" dictType="sys_yes_no" blankOption="true" class="form-control " /> +
+
+
+
+
+ +
+ <#form:input path="exceptionInfo" class="form-control "/> +
+
+
+
+
+
+
+ +
+ <#form:input path="userAgent" maxlength="500" class="form-control "/> +
+
+
+
+
+ +
+ <#form:input path="deviceName" maxlength="100" class="form-control "/> +
+
+
+
+
+
+
+ +
+ <#form:input path="browserName" maxlength="100" class="form-control "/> +
+
+
+
+
+ + +
+
+<% } %> + diff --git a/modules/core/src/main/resources/views/modules/sys/logList.html b/modules/core/src/main/resources/views/modules/sys/logList.html new file mode 100644 index 00000000..1fa63361 --- /dev/null +++ b/modules/core/src/main/resources/views/modules/sys/logList.html @@ -0,0 +1,151 @@ +<% layout('/layouts/default.html', {title: '访问日志查询', libs: ['dataGrid']}){ %> +
+
+
+
+ 访问日志查询 +
+
+ 查询 + <% if(hasPermi('sys:log:edit')){ %> + 新增 + <% } %> +
+
+
+ <#form:form id="searchForm" model="${log}" action="${ctx}/sys/log/listData" method="post" class="form-inline hide" + data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}"> +
+ +
+ <#form:input path="logTitle" maxlength="500" class="form-control width-90"/> +
+
+
+ +
+ <#form:input path="requestUri" maxlength="255" class="form-control width-90"/> +
+
+
+ +
+ <#form:select path="logType" dictType="sys_log_type" class="form-control required " /> +
+
+
+ +
+ <#form:input path="createBy.userCode" maxlength="64" class="form-control width-90"/> +
+
+
+ +
+ <#form:input path="createBy.userName" maxlength="100" class="form-control width-90"/> +
+
+
+
+ +
+ <#form:select path="isException" dictType="sys_yes_no" blankOption="true" class="form-control"/> +
+
+
+ +
+ <#form:input path="bizKey" maxlength="64" class="form-control width-90"/> +
+
+
+ +
+ <#form:input path="bizType" maxlength="64" class="form-control width-90"/> +
+
+
+ +
+ <#form:input path="createDate_gte" readonly="readonly" maxlength="20" class="form-control Wdate-date" + dataFormat="date" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false,onpicked:function(){createDate_lte.click()}});"/> +  --  + <#form:input path="createDate_lte" readonly="readonly" maxlength="20" class="form-control Wdate-date" + dataFormat="date" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/> +
+
+
+
+ +
+ <#form:input path="remoteAddr" maxlength="255" class="form-control width-90"/> +
+
+
+ +
+ <#form:input path="serverAddr" maxlength="255" class="form-control width-90"/> +
+
+
+ +
+ <#form:input path="deviceName" maxlength="100" class="form-control width-90"/> +
+
+
+ +
+ <#form:input path="browserName" maxlength="100" class="form-control width-90"/> +
+
+
+ + +
+ +
+
+
+
+
+<% } %> + \ No newline at end of file