Commit 6569f807 by fsn

完成日志管理根据条件查询

parent 2bd22986
......@@ -4,16 +4,17 @@ import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.common.constant.factory.PageFactory;
import com.stylefeng.guns.common.controller.BaseController;
import com.stylefeng.guns.core.support.BeanKit;
import com.stylefeng.guns.modular.system.dao.LogDao;
import com.stylefeng.guns.modular.system.warpper.LogWarpper;
import com.stylefeng.guns.persistence.dao.OperationLogMapper;
import com.stylefeng.guns.persistence.model.OperationLog;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
......@@ -32,6 +33,9 @@ public class LogController extends BaseController {
@Resource
private OperationLogMapper operationLogMapper;
@Resource
private LogDao logDao;
/**
* 跳转到日志管理的首页
*/
......@@ -45,10 +49,10 @@ public class LogController extends BaseController {
*/
@RequestMapping("/list")
@ResponseBody
public Object list(Date beginTime,Date endTime,String logName){
public Object list(@RequestParam(required = false) String beginTime, @RequestParam(required = false) String endTime, @RequestParam(required = false) String logName) {
Page<OperationLog> page = new PageFactory<OperationLog>().defaultPage();
List<Map<String, Object>> operationLogs = operationLogMapper.selectMapsPage(page, null);
page.setRecords((List<OperationLog>) new LogWarpper(operationLogs).warp());
List<Map<String, Object>> result = logDao.getOperationLogs(page, beginTime, endTime, logName);
page.setRecords((List<OperationLog>) new LogWarpper(result).warp());
return super.packForBT(page);
}
......@@ -57,7 +61,7 @@ public class LogController extends BaseController {
*/
@RequestMapping("/detail/{id}")
@ResponseBody
public Object detail(@PathVariable Integer id){
public Object detail(@PathVariable Integer id) {
OperationLog operationLog = operationLogMapper.selectById(id);
Map<String, Object> stringObjectMap = BeanKit.beanToMap(operationLog);
return super.warpObject(new LogWarpper(stringObjectMap));
......
package com.stylefeng.guns.modular.system.dao;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.persistence.model.OperationLog;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 日志记录dao
*
* @author stylefeng
* @Date 2017/4/16 23:44
*/
public interface LogDao{
/**
* 获取操作日志
*
* @author stylefeng
* @Date 2017/4/16 23:48
*/
List<Map<String, Object>> getOperationLogs(Page<OperationLog> page, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("logName") String logName);
}
<?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.stylefeng.guns.modular.system.dao.LogDao">
<select id="getOperationLogs" resultType="map">
select * from _operation_log where 1 = 1
<if test="beginTime != null and beginTime !='' and endTime != null and endTime != ''">
and (createTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
</if>
<if test="logName != null and logName !=''">
and logname like CONCAT('%',#{logName},'%')
</if>
</select>
</mapper>
\ No newline at end of file
......@@ -19,7 +19,7 @@
<#NameCon id="logName" name="日志名称" />
</div>
<div class="col-sm-3">
<#button name="搜索" icon="fa-search" clickFun="search()"/>
<#button name="搜索" icon="fa-search" clickFun="OptLog.search()"/>
</div>
</div>
<div class="hidden-xs" id="OptLogTableToolbar" role="group">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment