操作日志支持详细查询

This commit is contained in:
RuoYi 2018-03-03 01:02:21 +08:00
parent a91361d117
commit cf75297976
30 changed files with 270 additions and 238 deletions

View File

@ -186,8 +186,8 @@ create table sys_oper_log (
channel varchar(20) default '' comment '来源渠道', channel varchar(20) default '' comment '来源渠道',
login_name varchar(50) default '' comment '登录名称', login_name varchar(50) default '' comment '登录名称',
dept_name varchar(50) default '' comment '部门名称', dept_name varchar(50) default '' comment '部门名称',
opert_url varchar(255) default '' comment '请求URL', oper_url varchar(255) default '' comment '请求URL',
opert_ip varchar(30) default '' comment '操作地址', oper_ip varchar(30) default '' comment '主机地址',
oper_param varchar(255) default '' comment '请求参数', oper_param varchar(255) default '' comment '请求参数',
status int(1) default 0 comment '操作状态 0正常 1异常', status int(1) default 0 comment '操作状态 0正常 1异常',
error_msg varchar(255) default '' comment '错误消息', error_msg varchar(255) default '' comment '错误消息',
@ -195,7 +195,7 @@ create table sys_oper_log (
primary key (oper_id) primary key (oper_id)
) engine=innodb auto_increment=100 default charset=utf8; ) engine=innodb auto_increment=100 default charset=utf8;
insert into sys_oper_log values(1, '监控管理', '在线用户-踢出用户', 'com.ruoyi.project.monitor.online.controller.UserOnlineController()', 'web', 'admin', '研发部门', 'delete.do?id=1', '127.0.0.1', 'JSON参数', 0, '错误描述', '2018-01-01'); insert into sys_oper_log values(1, '监控管理', '在线用户-强退用户', 'com.ruoyi.project.monitor.online.controller.UserOnlineController()', 'web', 'admin', '研发部门', 'delete.do?id=1', '127.0.0.1', 'JSON参数', 0, '错误描述', '2018-01-01');
-- ---------------------------- -- ----------------------------
-- 8、数据字典表 -- 8、数据字典表

View File

@ -84,8 +84,8 @@ public class LogAspect
operLog.setStatus(UserConstants.NORMAL); operLog.setStatus(UserConstants.NORMAL);
// 请求的地址 // 请求的地址
String ip = ShiroUtils.getIp(); String ip = ShiroUtils.getIp();
operLog.setOpertIp(ip); operLog.setOperIp(ip);
operLog.setOpertUrl(HttpContextUtils.getHttpServletRequest().getRequestURI()); operLog.setOperUrl(HttpContextUtils.getHttpServletRequest().getRequestURI());
if (currentUser != null) if (currentUser != null)
{ {
operLog.setLoginName(currentUser.getLoginName()); operLog.setLoginName(currentUser.getLoginName());
@ -148,7 +148,7 @@ public class LogAspect
{ {
Map<String, String[]> map = HttpContextUtils.getHttpServletRequest().getParameterMap(); Map<String, String[]> map = HttpContextUtils.getHttpServletRequest().getParameterMap();
String params = JSONObject.toJSONString(map); String params = JSONObject.toJSONString(map);
operLog.setOpertParam(params); operLog.setOperParam(params);
} }
/** /**

View File

@ -55,7 +55,7 @@ public class LoginService
} }
// 查询用户信息 // 查询用户信息
User user = userService.selectByUserName(username); User user = userService.selectUserByName(username);
if (user == null) if (user == null)
{ {

View File

@ -53,7 +53,7 @@ public class OnlineSessionDAO extends EnterpriseCacheSessionDAO
@Override @Override
protected Session doReadSession(Serializable sessionId) protected Session doReadSession(Serializable sessionId)
{ {
UserOnline userOnline = onlineService.selectByOnlineId(String.valueOf(sessionId)); UserOnline userOnline = onlineService.selectOnlineById(String.valueOf(sessionId));
if (userOnline == null) if (userOnline == null)
{ {
return null; return null;
@ -95,7 +95,7 @@ public class OnlineSessionDAO extends EnterpriseCacheSessionDAO
{ {
onlineSession.resetAttributeChanged(); onlineSession.resetAttributeChanged();
} }
onlineService.saveByOnline(UserOnline.fromOnlineSession(onlineSession)); onlineService.saveOnline(UserOnline.fromOnlineSession(onlineSession));
} }
/** /**
@ -110,6 +110,6 @@ public class OnlineSessionDAO extends EnterpriseCacheSessionDAO
return; return;
} }
onlineSession.setStatus(OnlineSession.OnlineStatus.off_line); onlineSession.setStatus(OnlineSession.OnlineStatus.off_line);
onlineService.deleteByOnlineId(String.valueOf(onlineSession.getId())); onlineService.deleteOnlineById(String.valueOf(onlineSession.getId()));
} }
} }

View File

@ -91,7 +91,7 @@ public class OnlineWebSessionManager extends DefaultWebSessionManager
int timeout = (int) this.getGlobalSessionTimeout(); int timeout = (int) this.getGlobalSessionTimeout();
Date expiredDate = DateUtils.addMilliseconds(new Date(), 0 - timeout); Date expiredDate = DateUtils.addMilliseconds(new Date(), 0 - timeout);
UserOnlineServiceImpl userOnlineService = SpringUtils.getBean(UserOnlineServiceImpl.class); UserOnlineServiceImpl userOnlineService = SpringUtils.getBean(UserOnlineServiceImpl.class);
List<UserOnline> userOnlineList = userOnlineService.selectByOnlineExpired(expiredDate); List<UserOnline> userOnlineList = userOnlineService.selectOnlineByExpired(expiredDate);
// 批量过期删除 // 批量过期删除
List<String> needOfflineIdList = new ArrayList<String>(); List<String> needOfflineIdList = new ArrayList<String>();
for (UserOnline userOnline : userOnlineList) for (UserOnline userOnline : userOnlineList)
@ -123,7 +123,7 @@ public class OnlineWebSessionManager extends DefaultWebSessionManager
{ {
try try
{ {
userOnlineService.batchDeleteByOnline(needOfflineIdList); userOnlineService.batchDeleteOnline(needOfflineIdList);
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -61,7 +61,7 @@ public class UserOnlineController extends BaseController
{ {
for (String sessionId : ids) for (String sessionId : ids)
{ {
UserOnline online = userOnlineService.selectByOnlineId(sessionId); UserOnline online = userOnlineService.selectOnlineById(sessionId);
if (online == null) if (online == null)
{ {
return JSON.error("用户已下线"); return JSON.error("用户已下线");
@ -73,17 +73,17 @@ public class UserOnlineController extends BaseController
} }
onlineSession.setStatus(OnlineSession.OnlineStatus.off_line); onlineSession.setStatus(OnlineSession.OnlineStatus.off_line);
online.setStatus(OnlineSession.OnlineStatus.off_line); online.setStatus(OnlineSession.OnlineStatus.off_line);
userOnlineService.saveByOnline(online); userOnlineService.saveOnline(online);
} }
return JSON.ok(); return JSON.ok();
} }
@Log(title = "监控管理", action = "在线用户-踢出用户") @Log(title = "监控管理", action = "在线用户-强退用户")
@RequestMapping("/forceLogout/{sessionId}") @RequestMapping("/forceLogout/{sessionId}")
@ResponseBody @ResponseBody
public JSON forceLogout(@PathVariable("sessionId") String sessionId) public JSON forceLogout(@PathVariable("sessionId") String sessionId)
{ {
UserOnline online = userOnlineService.selectByOnlineId(sessionId); UserOnline online = userOnlineService.selectOnlineById(sessionId);
if (online == null) if (online == null)
{ {
return JSON.error("用户已下线"); return JSON.error("用户已下线");
@ -95,7 +95,7 @@ public class UserOnlineController extends BaseController
} }
onlineSession.setStatus(OnlineSession.OnlineStatus.off_line); onlineSession.setStatus(OnlineSession.OnlineStatus.off_line);
online.setStatus(OnlineSession.OnlineStatus.off_line); online.setStatus(OnlineSession.OnlineStatus.off_line);
userOnlineService.saveByOnline(online); userOnlineService.saveOnline(online);
return JSON.ok(); return JSON.ok();
} }

View File

@ -18,7 +18,7 @@ public interface IUserOnlineDao
* @param sessionId 会话ID * @param sessionId 会话ID
* @return 在线用户信息 * @return 在线用户信息
*/ */
public UserOnline selectByOnlineId(String sessionId); public UserOnline selectOnlineById(String sessionId);
/** /**
* 通过会话序号删除信息 * 通过会话序号删除信息
@ -26,7 +26,7 @@ public interface IUserOnlineDao
* @param sessionId 会话ID * @param sessionId 会话ID
* @return 在线用户信息 * @return 在线用户信息
*/ */
public int deleteByOnlineId(String sessionId); public int deleteOnlineById(String sessionId);
/** /**
* 保存会话信息 * 保存会话信息
@ -34,7 +34,7 @@ public interface IUserOnlineDao
* @param online 会话信息 * @param online 会话信息
* @return 结果 * @return 结果
*/ */
public int saveByOnline(UserOnline online); public int saveOnline(UserOnline online);
/** /**
* 查询会话集合 * 查询会话集合
@ -50,5 +50,5 @@ public interface IUserOnlineDao
* @param lastAccessTime 过期时间 * @param lastAccessTime 过期时间
* @return 会话集合 * @return 会话集合
*/ */
public List<UserOnline> selectByOnlineExpired(String lastAccessTime); public List<UserOnline> selectOnlineByExpired(String lastAccessTime);
} }

View File

@ -21,9 +21,9 @@ public class UserOnlineDaoImpl extends DynamicObjectBaseDao implements IUserOnli
* @return 在线用户信息 * @return 在线用户信息
*/ */
@Override @Override
public UserOnline selectByOnlineId(String sessionId) public UserOnline selectOnlineById(String sessionId)
{ {
return this.findForObject("SystemOnlineMapper.selectByOnlineId", sessionId); return this.findForObject("SystemOnlineMapper.selectOnlineById", sessionId);
} }
/** /**
@ -33,9 +33,9 @@ public class UserOnlineDaoImpl extends DynamicObjectBaseDao implements IUserOnli
* @return 在线用户信息 * @return 在线用户信息
*/ */
@Override @Override
public int deleteByOnlineId(String sessionId) public int deleteOnlineById(String sessionId)
{ {
return this.delete("SystemOnlineMapper.deleteByOnlineId", sessionId); return this.delete("SystemOnlineMapper.deleteOnlineById", sessionId);
} }
/** /**
@ -44,9 +44,9 @@ public class UserOnlineDaoImpl extends DynamicObjectBaseDao implements IUserOnli
* @param online 会话信息 * @param online 会话信息
*/ */
@Override @Override
public int saveByOnline(UserOnline online) public int saveOnline(UserOnline online)
{ {
return this.save("SystemOnlineMapper.saveByOnline", online); return this.save("SystemOnlineMapper.saveOnline", online);
} }
/** /**
@ -75,12 +75,12 @@ public class UserOnlineDaoImpl extends DynamicObjectBaseDao implements IUserOnli
* @param lastAccessTime 过期时间 * @param lastAccessTime 过期时间
*/ */
@Override @Override
public List<UserOnline> selectByOnlineExpired(String lastAccessTime) public List<UserOnline> selectOnlineByExpired(String lastAccessTime)
{ {
List<UserOnline> userOnlineList = null; List<UserOnline> userOnlineList = null;
try try
{ {
userOnlineList = this.findForList("SystemOnlineMapper.selectByOnlineExpired", lastAccessTime); userOnlineList = this.findForList("SystemOnlineMapper.selectOnlineByExpired", lastAccessTime);
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -19,7 +19,7 @@ public interface IUserOnlineService
* @param sessionId 会话ID * @param sessionId 会话ID
* @return 在线用户信息 * @return 在线用户信息
*/ */
public UserOnline selectByOnlineId(String sessionId); public UserOnline selectOnlineById(String sessionId);
/** /**
* 通过会话序号删除信息 * 通过会话序号删除信息
@ -27,7 +27,7 @@ public interface IUserOnlineService
* @param sessionId 会话ID * @param sessionId 会话ID
* @return 在线用户信息 * @return 在线用户信息
*/ */
public void deleteByOnlineId(String sessionId); public void deleteOnlineById(String sessionId);
/** /**
* 通过会话序号删除信息 * 通过会话序号删除信息
@ -35,14 +35,14 @@ public interface IUserOnlineService
* @param sessions 会话ID集合 * @param sessions 会话ID集合
* @return 在线用户信息 * @return 在线用户信息
*/ */
public void batchDeleteByOnline(List<String> sessions); public void batchDeleteOnline(List<String> sessions);
/** /**
* 保存会话信息 * 保存会话信息
* *
* @param online 会话信息 * @param online 会话信息
*/ */
public void saveByOnline(UserOnline online); public void saveOnline(UserOnline online);
/** /**
* 查询会话集合 * 查询会话集合
@ -65,5 +65,5 @@ public interface IUserOnlineService
* @param expiredDate 有效期 * @param expiredDate 有效期
* @return 会话集合 * @return 会话集合
*/ */
public List<UserOnline> selectByOnlineExpired(Date expiredDate); public List<UserOnline> selectOnlineByExpired(Date expiredDate);
} }

View File

@ -34,9 +34,9 @@ public class UserOnlineServiceImpl implements IUserOnlineService
* @return 在线用户信息 * @return 在线用户信息
*/ */
@Override @Override
public UserOnline selectByOnlineId(String sessionId) public UserOnline selectOnlineById(String sessionId)
{ {
return userOnlineDao.selectByOnlineId(sessionId); return userOnlineDao.selectOnlineById(sessionId);
} }
/** /**
@ -46,12 +46,12 @@ public class UserOnlineServiceImpl implements IUserOnlineService
* @return 在线用户信息 * @return 在线用户信息
*/ */
@Override @Override
public void deleteByOnlineId(String sessionId) public void deleteOnlineById(String sessionId)
{ {
UserOnline userOnline = selectByOnlineId(sessionId); UserOnline userOnline = selectOnlineById(sessionId);
if (userOnline != null) if (userOnline != null)
{ {
userOnlineDao.deleteByOnlineId(sessionId); userOnlineDao.deleteOnlineById(sessionId);
} }
} }
@ -62,14 +62,14 @@ public class UserOnlineServiceImpl implements IUserOnlineService
* @return 在线用户信息 * @return 在线用户信息
*/ */
@Override @Override
public void batchDeleteByOnline(List<String> sessions) public void batchDeleteOnline(List<String> sessions)
{ {
for (String sessionId : sessions) for (String sessionId : sessions)
{ {
UserOnline userOnline = selectByOnlineId(sessionId); UserOnline userOnline = selectOnlineById(sessionId);
if (userOnline != null) if (userOnline != null)
{ {
userOnlineDao.deleteByOnlineId(sessionId); userOnlineDao.deleteOnlineById(sessionId);
} }
} }
} }
@ -80,9 +80,9 @@ public class UserOnlineServiceImpl implements IUserOnlineService
* @param online 会话信息 * @param online 会话信息
*/ */
@Override @Override
public void saveByOnline(UserOnline online) public void saveOnline(UserOnline online)
{ {
userOnlineDao.saveByOnline(online); userOnlineDao.saveOnline(online);
} }
/** /**
@ -110,7 +110,7 @@ public class UserOnlineServiceImpl implements IUserOnlineService
return; return;
} }
session.setTimeout(1000); session.setTimeout(1000);
userOnlineDao.deleteByOnlineId(sessionId); userOnlineDao.deleteOnlineById(sessionId);
} }
/** /**
@ -119,9 +119,9 @@ public class UserOnlineServiceImpl implements IUserOnlineService
* @param online 会话信息 * @param online 会话信息
*/ */
@Override @Override
public List<UserOnline> selectByOnlineExpired(Date expiredDate) public List<UserOnline> selectOnlineByExpired(Date expiredDate)
{ {
String lastAccessTime = DateUtils.dateTime("yyyy-MM-dd HH:mm:ss", expiredDate); String lastAccessTime = DateUtils.dateTime("yyyy-MM-dd HH:mm:ss", expiredDate);
return userOnlineDao.selectByOnlineExpired(lastAccessTime); return userOnlineDao.selectOnlineByExpired(lastAccessTime);
} }
} }

View File

@ -1,13 +1,17 @@
package com.ruoyi.project.monitor.operlog.controller; package com.ruoyi.project.monitor.operlog.controller;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log; import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.web.controller.BaseController; import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.JSON; import com.ruoyi.framework.web.domain.JSON;
@ -58,4 +62,12 @@ public class OperlogController extends BaseController
} }
return JSON.error(); return JSON.error();
} }
@GetMapping("/view/{operId}")
String edit(@PathVariable("operId") Long deptId, Model model)
{
OperLog operLog = operLogService.selectOperLogById(deptId);
model.addAttribute("operLog", operLog);
return prefix + "/view";
}
} }

View File

@ -30,7 +30,15 @@ public interface IOperLogDao
* 批量删除系统操作日志 * 批量删除系统操作日志
* *
* @param ids 需要删除的数据 * @param ids 需要删除的数据
* @return * @return 结果
*/ */
public int batchDeleteOperLog(Long[] ids); public int batchDeleteOperLog(Long[] ids);
/**
* 查询操作日志详细
*
* @param operId 操作ID
* @return 操作日志对象
*/
public OperLog selectOperLogById(Long operId);
} }

View File

@ -64,4 +64,15 @@ public class OperLogDaoImpl extends DynamicObjectBaseDao implements IOperLogDao
} }
return rows; return rows;
} }
/**
* 查询操作日志详细
*
* @param operId 操作ID
* @return 操作日志对象
*/
public OperLog selectOperLogById(Long operId)
{
return this.findForObject("SystemOperLogMapper.selectOperLogById", operId);
}
} }

View File

@ -26,11 +26,11 @@ public class OperLog
/** 部门名称 */ /** 部门名称 */
private String deptName; private String deptName;
/** 请求url */ /** 请求url */
private String opertUrl; private String operUrl;
/** 操作地址 */ /** 操作地址 */
private String opertIp; private String operIp;
/** 请求参数 */ /** 请求参数 */
private String opertParam; private String operParam;
/** 状态0正常 1异常 */ /** 状态0正常 1异常 */
private int status; private int status;
/** 错误消息 */ /** 错误消息 */

View File

@ -30,7 +30,15 @@ public interface IOperLogService
* 批量删除系统操作日志 * 批量删除系统操作日志
* *
* @param ids 需要删除的数据 * @param ids 需要删除的数据
* @return * @return 结果
*/ */
public int batchDeleteOperLog(Long[] ids); public int batchDeleteOperLog(Long[] ids);
/**
* 查询操作日志详细
*
* @param operId 操作ID
* @return 操作日志对象
*/
public OperLog selectOperLogById(Long operId);
} }

View File

@ -52,4 +52,15 @@ public class OperLogServiceImpl implements IOperLogService
{ {
return operLogDao.batchDeleteOperLog(ids); return operLogDao.batchDeleteOperLog(ids);
} }
/**
* 查询操作日志详细
*
* @param operId 操作ID
* @return 操作日志对象
*/
public OperLog selectOperLogById(Long operId)
{
return operLogDao.selectOperLogById(operId);
}
} }

View File

@ -27,6 +27,6 @@ public interface IUserDao
* @param userName 用户名 * @param userName 用户名
* @return 用户对象信息 * @return 用户对象信息
*/ */
public User selectByUserName(String userName); public User selectUserByName(String userName);
} }

View File

@ -45,9 +45,9 @@ public class UserDaoImpl extends DynamicObjectBaseDao implements IUserDao
* @return 用户对象信息 * @return 用户对象信息
*/ */
@Override @Override
public User selectByUserName(String username) public User selectUserByName(String username)
{ {
return this.findForObject("SystemUserMapper.selectByUserName", username); return this.findForObject("SystemUserMapper.selectUserByName", username);
} }
} }

View File

@ -27,5 +27,5 @@ public interface IUserService
* @param userName 用户名 * @param userName 用户名
* @return 用户对象信息 * @return 用户对象信息
*/ */
public User selectByUserName(String userName); public User selectUserByName(String userName);
} }

View File

@ -40,9 +40,9 @@ public class UserServiceImpl implements IUserService
* @return 用户对象信息 * @return 用户对象信息
*/ */
@Override @Override
public User selectByUserName(String userName) public User selectUserByName(String userName)
{ {
return userDao.selectByUserName(userName); return userDao.selectUserByName(userName);
} }
} }

View File

@ -7,8 +7,8 @@ spring:
datasource: datasource:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.jdbc.Driver driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://10.213.24.45:3306/ry?useUnicode=true&characterEncoding=utf8 #url: jdbc:mysql://10.213.24.45:3306/ry?useUnicode=true&characterEncoding=utf8
#url: jdbc:mysql://localhost:3306/ry?useUnicode=true&characterEncoding=utf8 url: jdbc:mysql://localhost:3306/ry?useUnicode=true&characterEncoding=utf8
username: root username: root
password: password password: password
# 初始化大小,最小,最大 # 初始化大小,最小,最大

View File

@ -25,18 +25,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="status" column="status" /> <result property="status" column="status" />
</resultMap> </resultMap>
<select id="selectByOnlineId" parameterType="String" resultMap="UserOnlineResult"> <select id="selectOnlineById" parameterType="String" resultMap="UserOnlineResult">
select * select *
from sys_user_online from sys_user_online
where sessionid = #{sessionid} where sessionid = #{sessionid}
</select> </select>
<insert id="saveByOnline" parameterType="UserOnline"> <insert id="saveOnline" parameterType="UserOnline">
replace into sys_user_online(sessionId, login_name, dept_name, ipaddr, browser, os, status, start_timestsamp, last_access_time, expire_time) replace into sys_user_online(sessionId, login_name, dept_name, ipaddr, browser, os, status, start_timestsamp, last_access_time, expire_time)
values (#{sessionId}, #{loginName}, #{deptName}, #{ipaddr}, #{browser}, #{os}, #{status}, #{startTimestamp}, #{lastAccessTime}, #{expireTime}) values (#{sessionId}, #{loginName}, #{deptName}, #{ipaddr}, #{browser}, #{os}, #{status}, #{startTimestamp}, #{lastAccessTime}, #{expireTime})
</insert> </insert>
<delete id="deleteByOnlineId" parameterType="String"> <delete id="deleteOnlineById" parameterType="String">
delete from sys_user_online where sessionId = #{sessionId} delete from sys_user_online where sessionId = #{sessionId}
</delete> </delete>
@ -49,7 +49,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where> </where>
</select> </select>
<select id="selectByOnlineExpired" parameterType="String" resultMap="UserOnlineResult"> <select id="selectOnlineByExpired" parameterType="String" resultMap="UserOnlineResult">
SELECT * FROM sys_user_online o SELECT * FROM sys_user_online o
WHERE o.last_access_time <![CDATA[ <= ]]> #{lastAccessTime} ORDER BY o.last_access_time ASC WHERE o.last_access_time <![CDATA[ <= ]]> #{lastAccessTime} ORDER BY o.last_access_time ASC
</select> </select>

View File

@ -12,17 +12,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="channel" column="channel" /> <result property="channel" column="channel" />
<result property="loginName" column="login_name" /> <result property="loginName" column="login_name" />
<result property="deptName" column="dept_name" /> <result property="deptName" column="dept_name" />
<result property="opertUrl" column="opert_url" /> <result property="operUrl" column="oper_url" />
<result property="opertIp" column="opert_ip" /> <result property="operIp" column="oper_ip" />
<result property="opertParam" column="oper_param" /> <result property="operParam" column="oper_param" />
<result property="status" column="status" /> <result property="status" column="status" />
<result property="errorMsg" column="error_msg" /> <result property="errorMsg" column="error_msg" />
<result property="operTime" column="oper_time" /> <result property="operTime" column="oper_time" />
</resultMap> </resultMap>
<insert id="insertOperlog" parameterType="OperLog"> <insert id="insertOperlog" parameterType="OperLog">
insert into sys_oper_log(oper_id, title, action, method, channel, login_name, dept_name, opert_url, opert_ip, oper_param, status, error_msg) insert into sys_oper_log(oper_id, title, action, method, channel, login_name, dept_name, oper_url, oper_ip, oper_param, status, error_msg)
values (#{operId}, #{title}, #{action}, #{method}, #{channel}, #{loginName}, #{deptName}, #{opertUrl}, #{opertIp}, #{opertParam}, #{status}, #{errorMsg}) values (#{operId}, #{title}, #{action}, #{method}, #{channel}, #{loginName}, #{deptName}, #{operUrl}, #{operIp}, #{operParam}, #{status}, #{errorMsg})
</insert> </insert>
<select id="pageInfoQueryOperLog" parameterType="PageUtilEntity" resultMap="OperLogResult"> <select id="pageInfoQueryOperLog" parameterType="PageUtilEntity" resultMap="OperLogResult">
@ -41,4 +41,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach> </foreach>
</delete> </delete>
<select id="selectOperLogById" parameterType="Long" resultMap="OperLogResult">
select *
from sys_oper_log
where oper_id = #{operId}
</select>
</mapper> </mapper>

View File

@ -31,7 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select * from sys_user select * from sys_user
</select> </select>
<select id="selectByUserName" parameterType="String" resultMap="UserResult"> <select id="selectUserByName" parameterType="String" resultMap="UserResult">
select u.user_id, u.dept_id, u.login_name, u.user_name, u.email, u.phonenumber, u.password, u.salt, u.status, u.refuse_des, u.create_time, select u.user_id, u.dept_id, u.login_name, u.user_name, u.email, u.phonenumber, u.password, u.salt, u.status, u.refuse_des, u.create_time,
d.dept_id, d.parent_id, d.dept_name, d.order_num, d.status as dept_status d.dept_id, d.parent_id, d.dept_name, d.order_num, d.status as dept_status
from sys_user u from sys_user u

View File

@ -1,165 +0,0 @@
/**
* Created by liuruijie on 2016/9/28.
* 前端控制
*/
//状态码
web_status = {
SUCCESS : "000",
FAIL : "001",
NO_LOGIN : "003",
NO_PRIVILEGE : "004"
};
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]);
return null;
}
function simpleSuccess(result) {
//如果成功,则读取后端返回的操作指令
if (result.status == web_status.SUCCESS) {
if(result['msg']){
alert(result.msg);
}
//刷新
if(result['refresh']){
window.location.reload();
return;
}
//返回
if(result['back']){
window.location.href = document.referrer;
}
//跳转
if(result['redirectUrl']!=null){
window.location.href = result.redirectUrl;
return;
}
return result.data;
}
//未登录
if (result.status == web_status.NO_LOGIN) {
alert("您还未登陆!");
window.location.href =
"http://127.0.0.1:8081/login.html?backToUrl="+encodeURIComponent(btoa(window.location.href));
}else{
//其他错误情况,直接弹出提示框
if(result.msg!=null){
alert(result.msg);
}
}
return null;
}
//对jquery的ajax方法再次封装
__ajax = function(url, data, success, type ,contentType){
success = success||function(data){};
data = data||{};
var config = {
url:url,
type:type,
dataType:"json",
data:data,
success:function(result){
success(simpleSuccess(result));
}
};
//如果需要token校验
if(contentType){
config.contentType = contentType;
}
var token = $.cookie("token");
if(token){
config.beforeSend = function (xhr) {
xhr.setRequestHeader("Authorization", "Basic " + btoa(token));
}
}
$.ajax(config)
};
//再再次封装
AJAX = {
GET:function(url, data, success){
__ajax(url, data, success, "get");
},
POST_JSON: function(url, data, success){
__ajax(url, data, success, "post", "application/json");
},
POST:function(url, data, success){
__ajax(url, data, success, "post");
},
DELETE: function(url, data, success){
__ajax(url, data, success, "delete");
},
PUT:function(url, data, success){
__ajax(url, data, success, "put", "application/json");
},
PATCH: function (url, data, success) {
__ajax(url, data, success, "patch", "application/json");
},
INCLUDE: function (url, id) {
$.ajax({
url:url,
type:"get",
dataType:"html",
error: function (code) {
$("#"+id).html("加载失败");
},
success: function (result) {
$("#"+id).html(result);
}
})
}
};
//
//
// function __act_ajax(url, data, success, type, contentType){
// if(!success&&type == 'get'){
// success = function(data){
// }
// }
// else if(!success){
// success = function(data){
// window.location.reload();
// }
// }
// var config = {
// url: url,
// data: data,
// type: type,
// dataType: "json",
// error: function(code){
// alert("失败! code = "+code.status);
// },
// success: function(result){
// success(result);
// }
// };
//
// if(contentType){
// config.contentType = contentType;
// }
// $.ajax(config);
// }
//
// ACT_AJAX = {
// GET:function(url, data, success){
// __act_ajax(url, data, success, "get");
// },
// POST:function(url, data, success){
// __act_ajax(url, data, success, "post");
// },
// PUT:function(url, data, success){
// __act_ajax(url, data, success, "put", "application/json");
// },
// DELETE:function(url, data, success){
// __act_ajax(url, data, success, "delete");
// },
// PATCH: function (url, data, success) {
// __act_ajax(url, data, success, "patch", "application/json");
// }
// };

View File

@ -0,0 +1,84 @@
/**
* 通用方法封装处理
* Copyright (c) 2018 ruoyi
*/
/*
参数解释
title 标题
url 请求的url
w 弹出层宽度缺省调默认值
h 弹出层高度缺省调默认值
*/
function layer_show(title, url, w, h) {
if (title == null || title == '') {
title = false;
};
if (url == null || url == '') {
url = "404.html";
};
if (w == null || w == '') {
w = 800;
};
if (h == null || h == '') {
h = ($(window).height() - 50);
};
layer.open({
type: 2,
area: [w + 'px', h + 'px'],
fix: false,
//不固定
maxmin: true,
shade: 0.4,
title: title,
content: url
});
}
/*关闭弹出框口*/
function layer_close() {
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
}
//状态码
web_status = {
SUCCESS: 0,
FAIL: 500
};
//对jquery的ajax方法再次封装
_ajax = function(url, data, success, type, contentType) {
success = success ||
function(data) {};
data = data || {};
var config = {
url: url,
type: type,
dataType: "json",
data: data,
success: function(result) {
success(simpleSuccess(result));
}
};
$.ajax(config)
};
/** 返回结果处理 */
function simpleSuccess(result) {
if (result.code == web_status.SUCCESS) {
if (result['msg']) {
layer.msg(result.msg, { icon: 1, time: 1000 });
}
//刷新
if (result['refresh']) {
refresh();
return;
}
return result;
} else {
if (result.msg != null) {
layer.alert(result.msg, { icon: 2, title: "系统提示" });
}
}
return null;
}

View File

@ -26,7 +26,7 @@ $(function() {
title: '部门名称' title: '部门名称'
}, },
{ {
field: 'opertIp', field: 'operIp',
title: '主机' title: '主机'
}, },
{ {
@ -57,7 +57,10 @@ $(function() {
initTable(columns, url); initTable(columns, url);
}); });
/*操作日志-详细*/
function view(id) { function view(id) {
var url = prefix + '/view/' + id;
layer_show("操作日志详细", url, '800', '500');
} }
function batchRemove() { function batchRemove() {

View File

@ -32,5 +32,6 @@
<script src="/js/plugins/jqTreeGrid/jquery.treegrid.extension.js"></script> <script src="/js/plugins/jqTreeGrid/jquery.treegrid.extension.js"></script>
<script src="/js/plugins/jqTreeGrid/jquery.treegrid.bootstrap3.js"></script> <script src="/js/plugins/jqTreeGrid/jquery.treegrid.bootstrap3.js"></script>
<script src="/ajax/libs/layer/layer.min.js"></script> <script src="/ajax/libs/layer/layer.min.js"></script>
<script src="/ruoyi/js/common.js?v=1.0.1"></script>
<script src="http://tajs.qq.com/stats?sId=62048022"></script> <script src="http://tajs.qq.com/stats?sId=62048022"></script>
</div> </div>

View File

@ -126,6 +126,6 @@
<script src="/js/bootstrap.min.js"></script> <script src="/js/bootstrap.min.js"></script>
<script src="/js/plugins/metisMenu/jquery.metisMenu.js"></script> <script src="/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="/js/plugins/slimscroll/jquery.slimscroll.min.js"></script> <script src="/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="/ruoyi/js/index.js?v=1.0.0"></script> <script src="/ruoyi/js/index.js?v=1.0.1"></script>
</body> </body>
</html> </html>

View File

@ -0,0 +1,53 @@
<!DOCTYPE html>
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org"
xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m-t" id="signupForm">
<div class="form-group">
<label class="col-sm-2 control-label">操作模块:</label>
<div class="form-control-static" th:text="${operLog.title} + ' / ' + ${operLog.action}">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">登录信息:</label>
<div class="form-control-static" th:text="${operLog.loginName} + ' / ' + ${operLog.deptName} + ' / ' + ${operLog.operIp}">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">请求地址:</label>
<div class="form-control-static" th:text="${operLog.operUrl}">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">操作方法:</label>
<div class="form-control-static" th:text="${operLog.method}">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">请求参数:</label>
<div class="form-control-static" th:text="${operLog.operParam}">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">状态:</label>
<div class="form-control-static" th:class="${operLog.status == 0 ? 'label label-primary' : 'label label-danger'}" th:text="${operLog.status == 0 ? '正常' : '异常'}">
</div>
</div>
<div class="form-group" th:style="'display:' + ${operLog.status == 0 ? 'none' : 'block'}">
<label class="col-sm-2 control-label">异常信息:</label>
<div class="form-control-static" th:text="${operLog.errorMsg}">
</div>
</div>
<div class="form-group">
<div class="form-control-static col-sm-offset-9">
<button onClick="layer_close();" class="btn btn-danger" type="submit">关闭</button>
</div>
</div>
</form>
</div>
<div th:include="include :: footer"></div>
</body>
</html>