操作日志新增方法名称
This commit is contained in:
parent
f88a906dc9
commit
f5e3b2cd22
|
|
@ -184,8 +184,9 @@ drop table if exists sys_oper_log;
|
|||
create table sys_oper_log (
|
||||
oper_id int(11) not null auto_increment comment '日志主键',
|
||||
title varchar(50) default '' comment '功能请求',
|
||||
action varchar(50) default '' comment '模块标题',
|
||||
channel varchar(50) default '' comment '来源渠道',
|
||||
action varchar(100) default '' comment '模块标题',
|
||||
method varchar(100) default '' comment '方法名称',
|
||||
channel varchar(20) default '' comment '来源渠道',
|
||||
login_name varchar(50) default '' comment '登录名称',
|
||||
dept_name varchar(50) default '' comment '部门名称',
|
||||
opert_url varchar(255) default '' comment '请求URL',
|
||||
|
|
@ -197,7 +198,7 @@ create table sys_oper_log (
|
|||
primary key (oper_id)
|
||||
) engine=innodb auto_increment=100 default charset=utf8;
|
||||
|
||||
insert into sys_oper_log values(1, '监控管理', '在线用户-踢出用户', 'web', 'admin', '研发部门', 'delete.do?id=1', '127.0.0.1', 'JSON参数', 0, '错误描述', '2018-01-01');
|
||||
insert into sys_oper_log values(1, '监控管理', '在线用户-踢出用户', 'com.ruoyi.xxx.xxx', 'web', 'admin', '研发部门', 'delete.do?id=1', '127.0.0.1', 'JSON参数', 0, '错误描述', '2018-01-01');
|
||||
|
||||
-- ----------------------------
|
||||
-- 8、数据字典表
|
||||
|
|
@ -5,13 +5,13 @@ import com.ruoyi.common.exception.user.UserException;
|
|||
/**
|
||||
* 验证码错误异常类
|
||||
*
|
||||
* @author y
|
||||
* @author yangzz
|
||||
*/
|
||||
public class JCaptchaException extends UserException
|
||||
public class CaptchaException extends UserException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public JCaptchaException()
|
||||
public CaptchaException()
|
||||
{
|
||||
super("user.jcaptcha.error", null);
|
||||
}
|
||||
|
|
@ -4,9 +4,13 @@ import java.text.ParseException;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 时间工具类
|
||||
*
|
||||
* @author yangzz
|
||||
*/
|
||||
public class DateUtils
|
||||
{
|
||||
|
||||
public static final String DEFAULT_YYYYMMDD = "yyyyMMddHHmmss";
|
||||
|
||||
public static final String DEFAULT_YYYY_MM_DD = "yyyy-MM-dd HH:mm:ss";
|
||||
|
|
|
|||
|
|
@ -63,7 +63,9 @@ public class TreeUtils
|
|||
}
|
||||
}
|
||||
|
||||
// 得到子节点列表
|
||||
/**
|
||||
* 得到子节点列表
|
||||
*/
|
||||
private static List<Menu> getChildList(List<Menu> list, Menu t)
|
||||
{
|
||||
|
||||
|
|
@ -133,13 +135,17 @@ public class TreeUtils
|
|||
}
|
||||
}
|
||||
|
||||
// 判断是否有子节点
|
||||
/**
|
||||
* 判断是否有子节点
|
||||
*/
|
||||
private static boolean hasChild(List<Menu> list, Menu t)
|
||||
{
|
||||
return getChildList(list, t).size() > 0 ? true : false;
|
||||
}
|
||||
|
||||
// 本地模拟数据测试
|
||||
/**
|
||||
* 本地模拟数据测试
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
long start = System.currentTimeMillis();
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import org.springframework.stereotype.Component;
|
|||
@Component
|
||||
public final class SpringUtils implements BeanFactoryPostProcessor
|
||||
{
|
||||
// Spring应用上下文环境
|
||||
/** Spring应用上下文环境 */
|
||||
private static ConfigurableListableBeanFactory beanFactory;
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
|||
import com.ruoyi.project.monitor.operlog.domain.OperLog;
|
||||
import com.ruoyi.project.monitor.operlog.service.IOperLogService;
|
||||
import com.ruoyi.project.system.user.domain.User;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
|
|
@ -76,6 +75,7 @@ public class LogAspect
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取当前的用户
|
||||
User currentUser = ShiroUtils.getUser();
|
||||
|
||||
|
|
@ -97,7 +97,10 @@ public class LogAspect
|
|||
operLog.setStatus(UserConstants.EXCEPTION);
|
||||
operLog.setErrorMsg(e.getMessage());
|
||||
}
|
||||
|
||||
// 设置方法名称
|
||||
String className = joinPoint.getTarget().getClass().getName();
|
||||
String methodName = joinPoint.getSignature().getName();
|
||||
operLog.setMethod(className + "." + methodName + "()");
|
||||
// 处理设置注解上的参数
|
||||
getControllerMethodDescription(controllerLog, operLog);
|
||||
// 保存数据库
|
||||
|
|
@ -143,8 +146,6 @@ public class LogAspect
|
|||
*/
|
||||
private static void setRequestValue(OperLog operLog)
|
||||
{
|
||||
if (operLog == null)
|
||||
operLog = new OperLog();
|
||||
Map<String, String[]> map = HttpContextUtils.getHttpServletRequest().getParameterMap();
|
||||
String params = JSONObject.toJSONString(map);
|
||||
operLog.setOpertParam(params);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import org.springframework.stereotype.Component;
|
|||
@ConfigurationProperties(prefix = "ruoyi")
|
||||
public class Configuration
|
||||
{
|
||||
// 上传路径
|
||||
/** 上传路径 */
|
||||
private String uploadPath;
|
||||
|
||||
public String getUploadPath()
|
||||
|
|
|
|||
|
|
@ -76,8 +76,8 @@ public class DruidConfig
|
|||
@Value("{spring.datasource.connectionProperties}")
|
||||
private String connectionProperties;
|
||||
|
||||
@Bean(initMethod = "init", destroyMethod = "close") // 声明其为Bean实例
|
||||
@Primary // 在同样的DataSource中,首先使用被标注的DataSource
|
||||
@Bean(initMethod = "init", destroyMethod = "close") /** 声明其为Bean实例 */
|
||||
@Primary /** 在同样的DataSource中,首先使用被标注的DataSource */
|
||||
public DataSource dataSource()
|
||||
{
|
||||
DruidDataSource datasource = new DruidDataSource();
|
||||
|
|
@ -87,7 +87,7 @@ public class DruidConfig
|
|||
datasource.setPassword(password);
|
||||
datasource.setDriverClassName(driverClassName);
|
||||
|
||||
// configuration
|
||||
/** configuration */
|
||||
datasource.setInitialSize(initialSize);
|
||||
datasource.setMinIdle(minIdle);
|
||||
datasource.setMaxActive(maxActive);
|
||||
|
|
@ -122,11 +122,11 @@ public class DruidConfig
|
|||
ServletRegistrationBean reg = new ServletRegistrationBean();
|
||||
reg.setServlet(new StatViewServlet());
|
||||
reg.addUrlMappings("/monitor/druid/*");
|
||||
// 白名单
|
||||
/** 白名单 */
|
||||
reg.addInitParameter("allow", "10.211.61.45,127.0.0.1");
|
||||
// IP黑名单(共同存在时,deny优先于allow)
|
||||
/** IP黑名单(共同存在时,deny优先于allow) */
|
||||
reg.addInitParameter("deny", "10.211.61.4");
|
||||
// 是否能够重置数据 禁用HTML页面上的“Reset All”功能
|
||||
/** 是否能够重置数据 禁用HTML页面上的“Reset All”功能 */
|
||||
reg.addInitParameter("resetEnable", "false");
|
||||
return reg;
|
||||
}
|
||||
|
|
@ -139,17 +139,17 @@ public class DruidConfig
|
|||
{
|
||||
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
|
||||
filterRegistrationBean.setFilter(new WebStatFilter());
|
||||
// 添加过滤规则.
|
||||
/** 添加过滤规则. */
|
||||
filterRegistrationBean.addUrlPatterns("/*");
|
||||
// 监控选项滤器
|
||||
/** 监控选项滤器 */
|
||||
filterRegistrationBean.addInitParameter("DruidWebStatFilter", "/*");
|
||||
// 添加不需要忽略的格式信息.
|
||||
/** 添加不需要忽略的格式信息. */
|
||||
filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/monitor/druid/*");
|
||||
// 配置profileEnable能够监控单个url调用的sql列表
|
||||
/** 配置profileEnable能够监控单个url调用的sql列表 */
|
||||
filterRegistrationBean.addInitParameter("profileEnable", "true");
|
||||
// 当前的cookie的用户
|
||||
/** 当前的cookie的用户 */
|
||||
filterRegistrationBean.addInitParameter("principalCookieName", "USER_COOKIE");
|
||||
// 当前的session的用户
|
||||
/** 当前的session的用户 */
|
||||
filterRegistrationBean.addInitParameter("principalSessionName", "USER_SESSION");
|
||||
return filterRegistrationBean;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import org.apache.shiro.realm.AuthorizingRealm;
|
|||
import org.apache.shiro.subject.PrincipalCollection;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.ruoyi.common.exception.JCaptchaException;
|
||||
import com.ruoyi.common.exception.CaptchaException;
|
||||
import com.ruoyi.common.exception.user.RoleBlockedException;
|
||||
import com.ruoyi.common.exception.user.UserBlockedException;
|
||||
import com.ruoyi.common.exception.user.UserNotExistsException;
|
||||
|
|
@ -82,7 +82,7 @@ public class UserRealm extends AuthorizingRealm
|
|||
user = loginService.login(username, password);
|
||||
}
|
||||
|
||||
catch (JCaptchaException e)
|
||||
catch (CaptchaException e)
|
||||
{
|
||||
throw new AuthenticationException(e.getMessage(), e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,11 @@ package com.ruoyi.framework.shiro.session;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.session.Session;
|
||||
import org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
import com.ruoyi.common.utils.HttpContextUtils;
|
||||
import com.ruoyi.project.monitor.online.domain.OnlineSession;
|
||||
import com.ruoyi.project.monitor.online.domain.UserOnline;
|
||||
|
|
@ -124,38 +121,4 @@ public class OnlineSessionDAO extends EnterpriseCacheSessionDAO
|
|||
onlineSession.setStatus(OnlineSession.OnlineStatus.off_line);
|
||||
onlineService.deleteByOnlineId(String.valueOf(onlineSession.getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否为静态链接
|
||||
*
|
||||
* @return true 是 false 否
|
||||
*/
|
||||
public boolean checkStaticLink(String uri)
|
||||
{
|
||||
boolean linkFlag = false;
|
||||
// 如果是登录请求,则不更新SESSION
|
||||
if (StringUtils.startsWithAny(uri,
|
||||
new String[] { "/monitor/online/forceLogout", "/login", "/logout", "/index", "/favicon.ico" }))
|
||||
{
|
||||
linkFlag = true;
|
||||
}
|
||||
// 如果是登录请求,则不更新SESSION
|
||||
if (StringUtils.endsWithAny(uri, new String[] { "/" }))
|
||||
{
|
||||
linkFlag = true;
|
||||
}
|
||||
// 如果是静态文件,则不更新SESSION
|
||||
if (StringUtils.startsWith(uri, "/css") && StringUtils.endsWith(uri, ".css")
|
||||
|| StringUtils.startsWith(uri, "/js") && StringUtils.endsWith(uri, ".js")
|
||||
|| StringUtils.startsWith(uri, "/img") && StringUtils.endsWith(uri, ".jpg")
|
||||
|| StringUtils.startsWith(uri, "/img") && StringUtils.endsWith(uri, ".png")
|
||||
|| StringUtils.startsWith(uri, "/fonts") && StringUtils.endsWith(uri, ".woff2")
|
||||
|| StringUtils.startsWith(uri, "/js") && StringUtils.endsWith(uri, ".css")
|
||||
|| StringUtils.startsWith(uri, "/css") && StringUtils.endsWith(uri, ".png")
|
||||
|| StringUtils.startsWith(uri, "/css") && StringUtils.endsWith(uri, ".woff2"))
|
||||
{
|
||||
linkFlag = true;
|
||||
}
|
||||
return linkFlag;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,6 @@ import lombok.extern.slf4j.Slf4j;
|
|||
@Slf4j
|
||||
public class OnlineWebSessionManager extends DefaultWebSessionManager
|
||||
{
|
||||
|
||||
|
||||
@Override
|
||||
public void setAttribute(SessionKey sessionKey, Object attributeKey, Object value) throws InvalidSessionException
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
package com.ruoyi.framework.web.domain;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 返回数据通用处理
|
||||
*
|
||||
* @author yangzz
|
||||
*/
|
||||
public class JSON extends HashMap<String, Object>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public JSON()
|
||||
{
|
||||
put("code", 0);
|
||||
put("msg", "操作成功");
|
||||
}
|
||||
|
||||
public static JSON error()
|
||||
{
|
||||
return error(1, "操作失败");
|
||||
}
|
||||
|
||||
public static JSON error(String msg)
|
||||
{
|
||||
return error(500, msg);
|
||||
}
|
||||
|
||||
public static JSON error(int code, String msg)
|
||||
{
|
||||
JSON json = new JSON();
|
||||
json.put("code", code);
|
||||
json.put("msg", msg);
|
||||
return json;
|
||||
}
|
||||
|
||||
public static JSON ok(String msg)
|
||||
{
|
||||
JSON json = new JSON();
|
||||
json.put("msg", msg);
|
||||
return json;
|
||||
}
|
||||
|
||||
public static JSON ok(Map<String, Object> map)
|
||||
{
|
||||
JSON json = new JSON();
|
||||
json.putAll(map);
|
||||
return json;
|
||||
}
|
||||
|
||||
public static JSON ok()
|
||||
{
|
||||
return new JSON();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSON put(String key, Object value)
|
||||
{
|
||||
super.put(key, value);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
package com.ruoyi.framework.web.domain;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 返回数据通用处理
|
||||
*
|
||||
* @author yangzz
|
||||
*/
|
||||
public class R extends HashMap<String, Object>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public R()
|
||||
{
|
||||
put("code", 0);
|
||||
put("msg", "操作成功");
|
||||
}
|
||||
|
||||
public static R error()
|
||||
{
|
||||
return error(1, "操作失败");
|
||||
}
|
||||
|
||||
public static R error(String msg)
|
||||
{
|
||||
return error(500, msg);
|
||||
}
|
||||
|
||||
public static R error(int code, String msg)
|
||||
{
|
||||
R r = new R();
|
||||
r.put("code", code);
|
||||
r.put("msg", msg);
|
||||
return r;
|
||||
}
|
||||
|
||||
public static R ok(String msg)
|
||||
{
|
||||
R r = new R();
|
||||
r.put("msg", msg);
|
||||
return r;
|
||||
}
|
||||
|
||||
public static R ok(Map<String, Object> map)
|
||||
{
|
||||
R r = new R();
|
||||
r.putAll(map);
|
||||
return r;
|
||||
}
|
||||
|
||||
public static R ok()
|
||||
{
|
||||
return new R();
|
||||
}
|
||||
|
||||
@Override
|
||||
public R put(String key, Object value)
|
||||
{
|
||||
super.put(key, value);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@ package com.ruoyi.framework.web.exception;
|
|||
import org.apache.shiro.authz.AuthorizationException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import com.ruoyi.framework.web.domain.R;
|
||||
import com.ruoyi.framework.web.domain.JSON;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
|
@ -19,17 +19,17 @@ public class DefaultExceptionHandler
|
|||
{
|
||||
|
||||
@ExceptionHandler(AuthorizationException.class)
|
||||
public R handleAuthorizationException(AuthorizationException e)
|
||||
public JSON handleAuthorizationException(AuthorizationException e)
|
||||
{
|
||||
log.error(e.getMessage(), e);
|
||||
return R.error("未授权");
|
||||
return JSON.error("未授权");
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public R handleException(Exception e)
|
||||
public JSON handleException(Exception e)
|
||||
{
|
||||
log.error(e.getMessage(), e);
|
||||
return R.error("服务器错误," + e.getMessage());
|
||||
return JSON.error("服务器错误," + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,23 +10,23 @@ import com.ruoyi.common.utils.StringUtils;
|
|||
*/
|
||||
public class PageUtilEntity
|
||||
{
|
||||
// 总页数
|
||||
/** 总页数 */
|
||||
private int totalPage;
|
||||
// 当前记录起始索引
|
||||
/** 当前记录起始索引 */
|
||||
private int page;
|
||||
// 每页显示记录数
|
||||
/** 每页显示记录数 */
|
||||
private int size;
|
||||
// 排序列
|
||||
/** 排序列 */
|
||||
private String orderByColumn;
|
||||
// 排序的方向 "desc" 或者 "asc".
|
||||
/** 排序的方向 "desc" 或者 "asc". */
|
||||
private String isAsc;
|
||||
// 排序
|
||||
/** 排序 */
|
||||
protected String orderCond;
|
||||
// true:需要分页的地方,传入的参数就是Page实体;false:需要分页的地方,传入的参数所代表的实体拥有Page属性
|
||||
/** true:需要分页的地方,传入的参数就是Page实体;false:需要分页的地方,传入的参数所代表的实体拥有Page属性 */
|
||||
private boolean entityOrField;
|
||||
// 总记录数
|
||||
/** 总记录数 */
|
||||
private int totalResult;
|
||||
// 请求参数
|
||||
/** 请求参数 */
|
||||
protected Map<String, String> relationMap;
|
||||
|
||||
public int getTotalPage()
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ import java.util.List;
|
|||
public class TableDataInfo implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
// 总记录数
|
||||
/** 总记录数 */
|
||||
private int total;
|
||||
// 列表数据
|
||||
/** 列表数据 */
|
||||
private List<?> rows;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -15,16 +15,20 @@ import com.ruoyi.common.utils.StringUtils;
|
|||
import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
||||
import com.ruoyi.framework.shiro.session.OnlineSessionDAO;
|
||||
import com.ruoyi.framework.web.controller.BaseController;
|
||||
import com.ruoyi.framework.web.domain.R;
|
||||
import com.ruoyi.framework.web.domain.JSON;
|
||||
import com.ruoyi.project.monitor.online.domain.OnlineSession;
|
||||
import com.ruoyi.project.monitor.online.domain.UserOnline;
|
||||
import com.ruoyi.project.monitor.online.service.IUserOnlineService;
|
||||
|
||||
/**
|
||||
* 在线用户监控
|
||||
*
|
||||
* @author yangzz
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/monitor/online")
|
||||
public class UserOnlineController extends BaseController
|
||||
{
|
||||
|
||||
private String prefix = "monitor/online";
|
||||
|
||||
@Autowired
|
||||
|
|
@ -49,7 +53,7 @@ public class UserOnlineController extends BaseController
|
|||
|
||||
@GetMapping("/forceLogout")
|
||||
@ResponseBody
|
||||
public R forceLogout(@RequestParam(value = "ids") String[] ids)
|
||||
public JSON forceLogout(@RequestParam(value = "ids") String[] ids)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -62,7 +66,7 @@ public class UserOnlineController extends BaseController
|
|||
}
|
||||
userOnlineService.forceLogout(sessionId);
|
||||
}
|
||||
return R.ok();
|
||||
return JSON.ok();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
@ -71,29 +75,29 @@ public class UserOnlineController extends BaseController
|
|||
{
|
||||
msg = e.getMessage();
|
||||
}
|
||||
return R.error(msg);
|
||||
return JSON.error(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Log(title = "监控管理", action = "在线用户-踢出用户")
|
||||
@RequestMapping("/forceLogout/{sessionId}")
|
||||
@ResponseBody
|
||||
public R forceLogout(@PathVariable("sessionId") String sessionId)
|
||||
public JSON forceLogout(@PathVariable("sessionId") String sessionId)
|
||||
{
|
||||
UserOnline online = userOnlineService.selectByOnlineId(sessionId);
|
||||
if (online == null)
|
||||
{
|
||||
return R.error("用户已下线。数据不存在");
|
||||
return JSON.error("用户已下线。数据不存在");
|
||||
}
|
||||
OnlineSession onlineSession = (OnlineSession) onlineSessionDAO.readSession(online.getSessionId());
|
||||
if (onlineSession == null)
|
||||
{
|
||||
return R.error("用户已下线。会话不存在");
|
||||
return JSON.error("用户已下线。会话不存在");
|
||||
}
|
||||
onlineSession.setStatus(OnlineSession.OnlineStatus.off_line);
|
||||
online.setStatus(OnlineSession.OnlineStatus.off_line);
|
||||
userOnlineService.saveByOnline(online);
|
||||
return R.ok();
|
||||
return JSON.ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ import java.util.List;
|
|||
|
||||
import com.ruoyi.project.monitor.online.domain.UserOnline;
|
||||
|
||||
/**
|
||||
* 在线用户 服务层
|
||||
*
|
||||
* @author yangzz
|
||||
*/
|
||||
public interface IUserOnlineDao
|
||||
{
|
||||
/**
|
||||
|
|
@ -26,6 +31,7 @@ public interface IUserOnlineDao
|
|||
* 保存会话信息
|
||||
*
|
||||
* @param online 会话信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int saveByOnline(UserOnline online);
|
||||
|
||||
|
|
@ -33,14 +39,15 @@ public interface IUserOnlineDao
|
|||
* 查询会话集合
|
||||
*
|
||||
* @param online 会话信息
|
||||
* @return 会话集合
|
||||
*/
|
||||
public List<UserOnline> selectUserOnlines();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询过期会话集合
|
||||
*
|
||||
* @param lastAccessTime 过期时间
|
||||
* @return 会话集合
|
||||
*/
|
||||
public List<UserOnline> selectByOnlineExpired(String lastAccessTime);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,10 +2,15 @@ package com.ruoyi.project.monitor.online.dao;
|
|||
|
||||
import java.util.List;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.ruoyi.framework.web.dao.DynamicObjectBaseDao;
|
||||
import com.ruoyi.project.monitor.online.domain.UserOnline;
|
||||
|
||||
|
||||
/**
|
||||
* 在线用户数据层
|
||||
*
|
||||
* @author yangzz
|
||||
*/
|
||||
@Repository("userOnlineDao")
|
||||
public class UserOnlineDaoImpl extends DynamicObjectBaseDao implements IUserOnlineDao
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,35 +3,37 @@ package com.ruoyi.project.monitor.online.domain;
|
|||
import org.apache.shiro.session.mgt.SimpleSession;
|
||||
|
||||
/**
|
||||
* 在线用户会话属性
|
||||
*
|
||||
* @author yangzz
|
||||
*/
|
||||
public class OnlineSession extends SimpleSession
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// 用户ID
|
||||
/** 用户ID */
|
||||
private Long userId;
|
||||
|
||||
// 用户名称
|
||||
/** 用户名称 */
|
||||
private String loginName;
|
||||
|
||||
// 部门名称
|
||||
/** 部门名称 */
|
||||
private String deptName;
|
||||
|
||||
// 登录IP地址
|
||||
/** 登录IP地址 */
|
||||
private String host;
|
||||
|
||||
// 浏览器类型
|
||||
/** 浏览器类型 */
|
||||
private String browser;
|
||||
|
||||
// 操作系统
|
||||
/** 操作系统 */
|
||||
private String os;
|
||||
|
||||
// 在线状态
|
||||
/** 在线状态 */
|
||||
private OnlineStatus status = OnlineStatus.on_line;
|
||||
|
||||
// 属性是否改变 优化session数据同步
|
||||
/** 属性是否改变 优化session数据同步 */
|
||||
private transient boolean attributeChanged = false;
|
||||
|
||||
@Override
|
||||
|
|
@ -135,6 +137,7 @@ public class OnlineSession extends SimpleSession
|
|||
|
||||
public static enum OnlineStatus
|
||||
{
|
||||
/** 用户状态 */
|
||||
on_line("在线"), off_line("离线");
|
||||
private final String info;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,37 +14,37 @@ import lombok.Data;
|
|||
@Data
|
||||
public class UserOnline
|
||||
{
|
||||
// 用户会话id
|
||||
/** 用户会话id */
|
||||
private String sessionId;
|
||||
|
||||
// 部门名称
|
||||
/** 部门名称 */
|
||||
private String deptName;
|
||||
|
||||
// 登录名称
|
||||
/** 登录名称 */
|
||||
private String loginName;
|
||||
|
||||
// 登录IP地址
|
||||
/** 登录IP地址 */
|
||||
private String ipaddr;
|
||||
|
||||
// 浏览器类型
|
||||
/** 浏览器类型 */
|
||||
private String browser;
|
||||
|
||||
// 操作系统
|
||||
/** 操作系统 */
|
||||
private String os;
|
||||
|
||||
// session创建时间
|
||||
/** session创建时间 */
|
||||
private Date startTimestamp;
|
||||
|
||||
// session最后访问时间
|
||||
/** session最后访问时间 */
|
||||
private Date lastAccessTime;
|
||||
|
||||
// 超时时间,单位为分钟
|
||||
/** 超时时间,单位为分钟 */
|
||||
private Long expireTime;
|
||||
|
||||
// 在线状态
|
||||
/** 在线状态 */
|
||||
private OnlineStatus status = OnlineStatus.on_line;
|
||||
|
||||
// 备份的当前用户会话
|
||||
/** 备份的当前用户会话 */
|
||||
private OnlineSession session;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@ import java.util.List;
|
|||
|
||||
import com.ruoyi.project.monitor.online.domain.UserOnline;
|
||||
|
||||
/**
|
||||
* 在线用户 服务层
|
||||
*
|
||||
* @author yangzz
|
||||
*/
|
||||
public interface IUserOnlineService
|
||||
{
|
||||
/**
|
||||
|
|
@ -41,7 +46,7 @@ public interface IUserOnlineService
|
|||
/**
|
||||
* 查询会话集合
|
||||
*
|
||||
* @param online 会话信息
|
||||
* @return 会话集合
|
||||
*/
|
||||
public List<UserOnline> selectUserOnlines();
|
||||
|
||||
|
|
@ -55,7 +60,8 @@ public interface IUserOnlineService
|
|||
/**
|
||||
* 查询会话集合
|
||||
*
|
||||
* @param online 会话信息
|
||||
* @param expiredDate 有效期
|
||||
* @return 会话集合
|
||||
*/
|
||||
public List<UserOnline> selectByOnlineExpired(Date expiredDate);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,11 @@ import com.ruoyi.framework.shiro.session.OnlineSessionDAO;
|
|||
import com.ruoyi.project.monitor.online.dao.IUserOnlineDao;
|
||||
import com.ruoyi.project.monitor.online.domain.UserOnline;
|
||||
|
||||
/**
|
||||
* 在线用户 服务层
|
||||
*
|
||||
* @author yangzz
|
||||
*/
|
||||
@Service("userOnlineService")
|
||||
public class UserOnlineServiceImpl implements IUserOnlineService
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@ import org.springframework.stereotype.Repository;
|
|||
import com.ruoyi.framework.web.dao.DynamicObjectBaseDao;
|
||||
import com.ruoyi.project.monitor.operlog.domain.OperLog;
|
||||
|
||||
/**
|
||||
* 操作日志记录 数据层
|
||||
*
|
||||
* @author yangzz
|
||||
*/
|
||||
@Repository("operLogDao")
|
||||
public class OperLogDaoImpl extends DynamicObjectBaseDao implements IOperLogDao
|
||||
{
|
||||
|
|
@ -13,6 +18,7 @@ public class OperLogDaoImpl extends DynamicObjectBaseDao implements IOperLogDao
|
|||
*
|
||||
* @param operLog 系统日志对象
|
||||
*/
|
||||
@Override
|
||||
public void insertOperlog(OperLog operLog)
|
||||
{
|
||||
this.save("SystemOperLogMapper.insertOperlog", operLog);
|
||||
|
|
|
|||
|
|
@ -11,28 +11,30 @@ import lombok.Data;
|
|||
@Data
|
||||
public class OperLog
|
||||
{
|
||||
// 日志主键
|
||||
/** 日志主键 */
|
||||
private Integer operId;
|
||||
// 模块标题
|
||||
/** 模块标题 */
|
||||
private String title;
|
||||
// 功能请求
|
||||
/** 功能请求 */
|
||||
private String action;
|
||||
// 来源渠道
|
||||
/** 请求方法 */
|
||||
private String method;
|
||||
/** 来源渠道 */
|
||||
private String channel;
|
||||
// 操作员名称
|
||||
/** 操作员名称 */
|
||||
private String loginName;
|
||||
// 部门名称
|
||||
/** 部门名称 */
|
||||
private String deptName;
|
||||
// 请求url
|
||||
/** 请求url */
|
||||
private String opertUrl;
|
||||
// 操作地址
|
||||
/** 操作地址 */
|
||||
private String opertIp;
|
||||
// 请求参数
|
||||
/** 请求参数 */
|
||||
private String opertParam;
|
||||
// 状态0正常 1异常
|
||||
/** 状态0正常 1异常 */
|
||||
private int status;
|
||||
// 错误消息
|
||||
/** 错误消息 */
|
||||
private String errorMsg;
|
||||
// 操作时间
|
||||
/** 操作时间 */
|
||||
private Date operTime;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ public class OperLogServiceImpl implements IOperLogService
|
|||
*
|
||||
* @param operLog 系统日志对象
|
||||
*/
|
||||
@Override
|
||||
public void insertOperlog(OperLog operLog)
|
||||
{
|
||||
operLogDao.insertOperlog(operLog);
|
||||
|
|
|
|||
|
|
@ -10,15 +10,15 @@ import lombok.Data;
|
|||
@Data
|
||||
public class Dept
|
||||
{
|
||||
// 部门ID
|
||||
/** 部门ID */
|
||||
private Long deptId;
|
||||
// 父部门ID
|
||||
/** 父部门ID */
|
||||
private Long parentId;
|
||||
// 部门名称
|
||||
/** 部门名称 */
|
||||
private String deptName;
|
||||
// 显示顺序
|
||||
/** 显示顺序 */
|
||||
private String orderNum;
|
||||
// 部门状态:0正常,1停用
|
||||
/** 部门状态:0正常,1停用 */
|
||||
private String status;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@ import org.springframework.stereotype.Repository;
|
|||
import com.ruoyi.framework.web.dao.DynamicObjectBaseDao;
|
||||
import com.ruoyi.project.system.logininfor.domain.Logininfor;
|
||||
|
||||
/**
|
||||
* 登录日志记录 数据层
|
||||
*
|
||||
* @author yangzz
|
||||
*/
|
||||
@Repository("logininforDao")
|
||||
public class LogininforDaoImpl extends DynamicObjectBaseDao implements ILogininforDao
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,21 +10,21 @@ import lombok.Data;
|
|||
@Data
|
||||
public class Logininfor
|
||||
{
|
||||
// ID
|
||||
/** ID */
|
||||
private Integer infoId;
|
||||
// 用户账号
|
||||
/** 用户账号 */
|
||||
private String loginName;
|
||||
// 登录状态 0成功 1失败
|
||||
/** 登录状态 0成功 1失败 */
|
||||
private String status;
|
||||
// 登录IP地址
|
||||
/** 登录IP地址 */
|
||||
private String ipaddr;
|
||||
// 浏览器类型
|
||||
/** 浏览器类型 */
|
||||
private String browser;
|
||||
// 操作系统
|
||||
/** 操作系统 */
|
||||
private String os;
|
||||
// 提示消息
|
||||
/** 提示消息 */
|
||||
private String msg;
|
||||
// 访问时间
|
||||
/** 访问时间 */
|
||||
private String loginTime;
|
||||
|
||||
}
|
||||
|
|
@ -12,33 +12,33 @@ import lombok.Data;
|
|||
@Data
|
||||
public class Menu
|
||||
{
|
||||
// 菜单ID
|
||||
/** 菜单ID */
|
||||
private Integer menuId;
|
||||
// 菜单名称
|
||||
/** 菜单名称 */
|
||||
private String menuName;
|
||||
// 父菜单ID
|
||||
/** 父菜单ID */
|
||||
private Integer parentId;
|
||||
// 显示顺序
|
||||
/** 显示顺序 */
|
||||
private String orderNum;
|
||||
// 菜单URL
|
||||
/** 菜单URL */
|
||||
private String url;
|
||||
// 类型:0目录,1菜单,2按钮
|
||||
/** 类型:0目录,1菜单,2按钮 */
|
||||
private String menuType;
|
||||
// 菜单状态:0显示,1隐藏
|
||||
/** 菜单状态:0显示,1隐藏 */
|
||||
private String visible;
|
||||
// 权限字符串
|
||||
/** 权限字符串 */
|
||||
private String perms;
|
||||
// 菜单图标
|
||||
/** 菜单图标 */
|
||||
private String icon;
|
||||
// 创建时间
|
||||
/** 创建时间 */
|
||||
private String createTime;
|
||||
// 更新时间
|
||||
/** 更新时间 */
|
||||
private String updateTime;
|
||||
// 更新者
|
||||
/** 更新者 */
|
||||
private String updateBy;
|
||||
// 备注
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
// 子菜单
|
||||
/** 子菜单 */
|
||||
private List<Menu> children = new ArrayList<Menu>();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,21 +10,21 @@ import lombok.Data;
|
|||
@Data
|
||||
public class Role
|
||||
{
|
||||
// 角色ID
|
||||
/** 角色ID */
|
||||
private Long roleId;
|
||||
// 角色名
|
||||
/** 角色名 */
|
||||
private String roleName;
|
||||
// 角色权限
|
||||
/** 角色权限 */
|
||||
private String roleKey;
|
||||
// 角色状态:0正常,1禁用
|
||||
/** 角色状态:0正常,1禁用 */
|
||||
private String status;
|
||||
// 创建时间
|
||||
/** 创建时间 */
|
||||
private String createTime;
|
||||
// 更新时间
|
||||
/** 更新时间 */
|
||||
private String updateTime;
|
||||
// 更新者
|
||||
/** 更新者 */
|
||||
private String updateBy;
|
||||
// 备注
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.framework.web.controller.BaseController;
|
||||
import com.ruoyi.framework.web.domain.R;
|
||||
import com.ruoyi.framework.web.domain.JSON;
|
||||
|
||||
/**
|
||||
* 登录验证
|
||||
|
|
@ -30,14 +30,14 @@ public class LoginController extends BaseController
|
|||
|
||||
@PostMapping("/login")
|
||||
@ResponseBody
|
||||
public R ajaxLogin(String username, String password)
|
||||
public JSON ajaxLogin(String username, String password)
|
||||
{
|
||||
UsernamePasswordToken token = new UsernamePasswordToken(username, password);
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
try
|
||||
{
|
||||
subject.login(token);
|
||||
return R.ok();
|
||||
return JSON.ok();
|
||||
}
|
||||
catch (AuthenticationException e)
|
||||
{
|
||||
|
|
@ -46,7 +46,7 @@ public class LoginController extends BaseController
|
|||
{
|
||||
msg = e.getMessage();
|
||||
}
|
||||
return R.error(msg);
|
||||
return JSON.error(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,29 +11,29 @@ import lombok.Data;
|
|||
@Data
|
||||
public class User
|
||||
{
|
||||
// 用户ID
|
||||
/** 用户ID */
|
||||
private Long userId;
|
||||
// 部门ID
|
||||
/** 部门ID */
|
||||
private Long deptId;
|
||||
// 登录名
|
||||
/** 登录名 */
|
||||
private String loginName;
|
||||
// 用户名称
|
||||
/** 用户名称 */
|
||||
private String userName;
|
||||
// 用户邮箱
|
||||
/** 用户邮箱 */
|
||||
private String email;
|
||||
// 手机号码
|
||||
/** 手机号码 */
|
||||
private String phonenumber;
|
||||
// 密码
|
||||
/** 密码 */
|
||||
private String password;
|
||||
// 盐加密
|
||||
/** 盐加密 */
|
||||
private String salt;
|
||||
// 帐号状态:0正常,1锁定,2黑名单,3禁止
|
||||
/** 帐号状态:0正常,1锁定,2黑名单,3禁止 */
|
||||
private String status;
|
||||
// 拒绝登录描述
|
||||
/** 拒绝登录描述 */
|
||||
private String refuseDes;
|
||||
// 创建时间
|
||||
/** 创建时间 */
|
||||
private String createTime;
|
||||
// 部门对象
|
||||
/** 部门对象 */
|
||||
private Dept dept;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<id property="operId" column="oper_id" />
|
||||
<result property="title" column="title" />
|
||||
<result property="action" column="action" />
|
||||
<result property="method" column="method" />
|
||||
<result property="channel" column="channel" />
|
||||
<result property="loginName" column="login_name" />
|
||||
<result property="deptName" column="dept_name" />
|
||||
|
|
@ -20,8 +21,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</resultMap>
|
||||
|
||||
<insert id="insertOperlog" parameterType="OperLog">
|
||||
insert into sys_oper_log(oper_id, title, action, channel, login_name, dept_name, opert_url, opert_ip, oper_param, status, error_msg)
|
||||
values (#{operId}, #{title}, #{action}, #{channel}, #{loginName}, #{deptName}, #{opertUrl}, #{opertIp}, #{opertParam}, #{status}, #{errorMsg})
|
||||
insert into sys_oper_log(oper_id, title, action, method, channel, login_name, dept_name, opert_url, opert_ip, oper_param, status, error_msg)
|
||||
values (#{operId}, #{title}, #{action}, #{method}, #{channel}, #{loginName}, #{deptName}, #{opertUrl}, #{opertIp}, #{opertParam}, #{status}, #{errorMsg})
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue