mirror of https://gitee.com/y_project/RuoYi.git
日志管理使用索引提升查询性能
parent
bee73e87a5
commit
1e91312f08
|
@ -68,6 +68,7 @@ $(function() {
|
|||
endLayDate.config.min.month = '';
|
||||
endLayDate.config.min.date = '';
|
||||
}
|
||||
$('#endTime').trigger('click');
|
||||
}
|
||||
});
|
||||
endLayDate = laydate.render({
|
||||
|
@ -383,6 +384,32 @@ function checkpwd(chrtype, password) {
|
|||
return true;
|
||||
}
|
||||
|
||||
/** 开始时间/时分秒 */
|
||||
function beginOfTime(date) {
|
||||
if($.common.isNotEmpty(date)) {
|
||||
return $.common.sprintf("%s 00:00:00", date);
|
||||
}
|
||||
}
|
||||
|
||||
/** 结束时间/时分秒 */
|
||||
function endOfTime(date) {
|
||||
if($.common.isNotEmpty(date)) {
|
||||
return $.common.sprintf("%s 23:59:59", date);
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置日期/年月日 */
|
||||
function resetDate() {
|
||||
if ($.common.isNotEmpty(startLayDate) && $.common.isNotEmpty(endLayDate)) {
|
||||
endLayDate.config.min.year = '';
|
||||
endLayDate.config.min.month = '';
|
||||
endLayDate.config.min.date = '';
|
||||
startLayDate.config.max.year = '2099';
|
||||
startLayDate.config.max.month = '12';
|
||||
startLayDate.config.max.date = '31';
|
||||
}
|
||||
}
|
||||
|
||||
// 日志打印封装处理
|
||||
var log = {
|
||||
log: function(msg) {
|
||||
|
|
|
@ -704,14 +704,7 @@ var table = {
|
|||
} else if (table.options.type == table_type.bootstrapTreeTable) {
|
||||
$("#" + tableId).bootstrapTreeTable('refresh', table.options.ajaxParams);
|
||||
}
|
||||
if ($.common.isNotEmpty(startLayDate) && $.common.isNotEmpty(endLayDate)) {
|
||||
endLayDate.config.min.year = '';
|
||||
endLayDate.config.min.month = '';
|
||||
endLayDate.config.min.date = '';
|
||||
startLayDate.config.max.year = '2099';
|
||||
startLayDate.config.max.month = '12';
|
||||
startLayDate.config.max.date = '31';
|
||||
}
|
||||
resetDate();
|
||||
},
|
||||
// 获取选中复选框项
|
||||
selectCheckeds: function(name) {
|
||||
|
|
|
@ -24,9 +24,9 @@
|
|||
</li>
|
||||
<li class="select-time">
|
||||
<label>登录时间: </label>
|
||||
<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
|
||||
<input type="text" class="time-input" id="startTime" placeholder="开始时间"/>
|
||||
<span>-</span>
|
||||
<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
|
||||
<input type="text" class="time-input" id="endTime" placeholder="结束时间"/>
|
||||
</li>
|
||||
<li>
|
||||
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i> 搜索</a>
|
||||
|
@ -69,6 +69,7 @@
|
|||
cleanUrl: prefix + "/clean",
|
||||
removeUrl: prefix + "/remove",
|
||||
exportUrl: prefix + "/export",
|
||||
queryParams: queryParams,
|
||||
sortName: "loginTime",
|
||||
sortOrder: "desc",
|
||||
modalName: "登录日志",
|
||||
|
@ -128,6 +129,15 @@
|
|||
$.table.init(options);
|
||||
});
|
||||
|
||||
function queryParams(params) {
|
||||
var search = $.table.queryParams(params);
|
||||
search.params = {
|
||||
beginTime : beginOfTime($("#startTime").val()),
|
||||
endTime : endOfTime($("#endTime").val())
|
||||
};
|
||||
return search;
|
||||
}
|
||||
|
||||
function unlock() {
|
||||
$.operate.post(prefix + "/unlock?loginName=" + $.table.selectColumns("loginName"));
|
||||
}
|
||||
|
|
|
@ -30,9 +30,9 @@
|
|||
</li>
|
||||
<li class="select-time">
|
||||
<label>操作时间: </label>
|
||||
<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
|
||||
<input type="text" class="time-input" id="startTime" placeholder="开始时间"/>
|
||||
<span>-</span>
|
||||
<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
|
||||
<input type="text" class="time-input" id="endTime" placeholder="结束时间"/>
|
||||
</li>
|
||||
<li>
|
||||
<a class="btn btn-primary btn-rounded btn-sm" onclick="searchPre()"><i class="fa fa-search"></i> 搜索</a>
|
||||
|
@ -92,14 +92,17 @@
|
|||
},
|
||||
{
|
||||
field: 'title',
|
||||
title: '系统模块'
|
||||
},
|
||||
title: '系统模块',
|
||||
formatter: function(value, row, index) {
|
||||
return $.table.tooltip(value);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'businessType',
|
||||
title: '操作类型',
|
||||
align: 'center',
|
||||
formatter: function(value, row, index) {
|
||||
return $.table.selectDictLabel(datas, value);
|
||||
return $.table.selectDictLabel(datas, value);
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -159,6 +162,10 @@
|
|||
|
||||
function queryParams(params) {
|
||||
var search = $.table.queryParams(params);
|
||||
search.params = {
|
||||
beginTime : beginOfTime($("#startTime").val()),
|
||||
endTime : endOfTime($("#endTime").val())
|
||||
};
|
||||
search.businessTypes = $.common.join($('#businessTypes').selectpicker('val'));
|
||||
return search;
|
||||
}
|
||||
|
@ -168,6 +175,7 @@
|
|||
}
|
||||
|
||||
function resetPre() {
|
||||
resetDate();
|
||||
$("#operlog-form")[0].reset();
|
||||
$("#businessTypes").selectpicker('refresh');
|
||||
$.table.search('operlog-form', 'bootstrap-table');
|
||||
|
|
|
@ -224,6 +224,7 @@
|
|||
|
||||
/* 自定义重置-表单重置/隐藏框/树节点选择色/搜索 */
|
||||
function resetPre() {
|
||||
resetDate();
|
||||
$("#user-form")[0].reset();
|
||||
$("#deptId").val("");
|
||||
$("#parentId").val("");
|
||||
|
|
|
@ -34,10 +34,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
AND login_name like concat('%', #{loginName}, '%')
|
||||
</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||
and date_format(login_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||
AND login_time >= #{params.beginTime}
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||
and date_format(login_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
AND login_time <= #{params.endTime}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
|
|
@ -56,10 +56,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
AND oper_name like concat('%', #{operName}, '%')
|
||||
</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||
and date_format(oper_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||
AND oper_time >= #{params.beginTime}
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||
and date_format(oper_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
AND oper_time <= #{params.endTime}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
|
|
@ -429,7 +429,10 @@ create table sys_oper_log (
|
|||
error_msg varchar(2000) default '' comment '错误消息',
|
||||
oper_time datetime comment '操作时间',
|
||||
cost_time bigint(20) default 0 comment '消耗时间',
|
||||
primary key (oper_id)
|
||||
primary key (oper_id),
|
||||
key idx_sys_oper_log_bt (business_type),
|
||||
key idx_sys_oper_log_s (status),
|
||||
key idx_sys_oper_log_ot (oper_time)
|
||||
) engine=innodb auto_increment=100 comment = '操作日志记录';
|
||||
|
||||
|
||||
|
@ -563,7 +566,9 @@ create table sys_logininfor (
|
|||
status char(1) default '0' comment '登录状态(0成功 1失败)',
|
||||
msg varchar(255) default '' comment '提示消息',
|
||||
login_time datetime comment '访问时间',
|
||||
primary key (info_id)
|
||||
primary key (info_id),
|
||||
key idx_sys_logininfor_s (status),
|
||||
key idx_sys_logininfor_lt (login_time)
|
||||
) engine=innodb auto_increment=100 comment = '系统访问记录';
|
||||
|
||||
|
Loading…
Reference in New Issue