增加在线用户表

pull/2/head
YunaiV 2021-01-29 01:16:54 +08:00
parent 46706eb069
commit b557251b6f
14 changed files with 107 additions and 215 deletions

View File

@ -1,48 +0,0 @@
package com.ruoyi.system.service;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.system.domain.SysUserOnline;
/**
* 线
*
* @author ruoyi
*/
public interface ISysUserOnlineService
{
/**
*
*
* @param ipaddr
* @param user
* @return 线
*/
public SysUserOnline selectOnlineByIpaddr(String ipaddr, LoginUser user);
/**
*
*
* @param userName
* @param user
* @return 线
*/
public SysUserOnline selectOnlineByUserName(String userName, LoginUser user);
/**
* /
*
* @param ipaddr
* @param userName
* @param user
* @return 线
*/
public SysUserOnline selectOnlineByInfo(String ipaddr, String userName, LoginUser user);
/**
* 线
*
* @param user
* @return 线
*/
public SysUserOnline loginUserToUserOnline(LoginUser user);
}

View File

@ -1,49 +0,0 @@
package com.ruoyi.system.domain;
/**
* 线
*
* @author ruoyi
*/
public class SysUserOnline {
/**
*
*/
private String tokenId;
/**
*
*/
private String deptName;
/**
*
*/
private String userName;
/**
* IP
*/
private String ipaddr;
/**
*
*/
private String loginLocation;
/**
*
*/
private String browser;
/**
*
*/
private String os;
/**
*
*/
private Long loginTime;
}

View File

@ -1,86 +0,0 @@
package com.ruoyi.system.service.impl;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.SysUserOnline;
import com.ruoyi.system.service.ISysUserOnlineService;
/**
* 线
*
* @author ruoyi
*/
@Service
public class SysUserOnlineServiceImpl implements ISysUserOnlineService {
/**
*
*
* @param ipaddr
* @param user
* @return 线
*/
@Override
public SysUserOnline selectOnlineByIpaddr(String ipaddr, LoginUser user) {
if (StringUtils.equals(ipaddr, user.getIpaddr())) {
return loginUserToUserOnline(user);
}
return null;
}
/**
*
*
* @param userName
* @param user
* @return 线
*/
@Override
public SysUserOnline selectOnlineByUserName(String userName, LoginUser user) {
if (StringUtils.equals(userName, user.getUsername())) {
return loginUserToUserOnline(user);
}
return null;
}
/**
* /
*
* @param ipaddr
* @param userName
* @param user
* @return 线
*/
@Override
public SysUserOnline selectOnlineByInfo(String ipaddr, String userName, LoginUser user) {
if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername())) {
return loginUserToUserOnline(user);
}
return null;
}
/**
* 线
*
* @param user
* @return 线
*/
@Override
public SysUserOnline loginUserToUserOnline(LoginUser user) {
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUser())) {
return null;
}
SysUserOnline sysUserOnline = new SysUserOnline();
sysUserOnline.setTokenId(user.getToken());
sysUserOnline.setUserName(user.getUsername());
sysUserOnline.setIpaddr(user.getIpaddr());
sysUserOnline.setLoginLocation(user.getLoginLocation());
sysUserOnline.setBrowser(user.getBrowser());
sysUserOnline.setOs(user.getOs());
sysUserOnline.setLoginTime(user.getLoginTime());
if (StringUtils.isNotNull(user.getUser().getDept())) {
sysUserOnline.setDeptName(user.getUser().getDept().getDeptName());
}
return sysUserOnline;
}
}

View File

@ -47,28 +47,6 @@ spring:
restart:
# 热部署开关
enabled: true
# redis 配置
redis:
# 地址
host: 127.0.0.1
# 端口默认为6379
port: 6379
# 数据库索引
database: 0
# 密码
password:
# 连接超时时间
timeout: 10s
lettuce:
pool:
# 连接池中的最小空闲连接
min-idle: 0
# 连接池中的最大空闲连接
max-idle: 8
# 连接池的最大数据库连接数
max-active: 8
# #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
# 防止XSS攻击
xss:

View File

@ -3,10 +3,10 @@ package cn.iocoder.dashboard.modules.system.controller.auth;
import cn.iocoder.dashboard.common.enums.CommonStatusEnum;
import cn.iocoder.dashboard.common.pojo.CommonResult;
import cn.iocoder.dashboard.framework.logger.operatelog.core.annotations.OperateLog;
import cn.iocoder.dashboard.modules.system.controller.auth.vo.SysAuthLoginReqVO;
import cn.iocoder.dashboard.modules.system.controller.auth.vo.SysAuthLoginRespVO;
import cn.iocoder.dashboard.modules.system.controller.auth.vo.SysAuthMenuRespVO;
import cn.iocoder.dashboard.modules.system.controller.auth.vo.SysAuthPermissionInfoRespVO;
import cn.iocoder.dashboard.modules.system.controller.auth.vo.auth.SysAuthLoginReqVO;
import cn.iocoder.dashboard.modules.system.controller.auth.vo.auth.SysAuthLoginRespVO;
import cn.iocoder.dashboard.modules.system.controller.auth.vo.auth.SysAuthMenuRespVO;
import cn.iocoder.dashboard.modules.system.controller.auth.vo.auth.SysAuthPermissionInfoRespVO;
import cn.iocoder.dashboard.modules.system.convert.auth.SysAuthConvert;
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysMenuDO;
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysRoleDO;

View File

@ -1,4 +1,4 @@
package cn.iocoder.dashboard.modules.system.controller.auth.vo;
package cn.iocoder.dashboard.modules.system.controller.auth.vo.auth;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

View File

@ -1,4 +1,4 @@
package cn.iocoder.dashboard.modules.system.controller.auth.vo;
package cn.iocoder.dashboard.modules.system.controller.auth.vo.auth;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

View File

@ -1,4 +1,4 @@
package cn.iocoder.dashboard.modules.system.controller.auth.vo;
package cn.iocoder.dashboard.modules.system.controller.auth.vo.auth;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

View File

@ -1,4 +1,4 @@
package cn.iocoder.dashboard.modules.system.controller.auth.vo;
package cn.iocoder.dashboard.modules.system.controller.auth.vo.auth;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

View File

@ -0,0 +1,12 @@
package cn.iocoder.dashboard.modules.system.controller.auth.vo.session;
import cn.iocoder.dashboard.common.pojo.PageParam;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ApiModel("在线用户 Session 分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
public class SysUserSessionPageReqVO extends PageParam {
}

View File

@ -1,8 +1,8 @@
package cn.iocoder.dashboard.modules.system.convert.auth;
import cn.iocoder.dashboard.framework.security.core.LoginUser;
import cn.iocoder.dashboard.modules.system.controller.auth.vo.SysAuthMenuRespVO;
import cn.iocoder.dashboard.modules.system.controller.auth.vo.SysAuthPermissionInfoRespVO;
import cn.iocoder.dashboard.modules.system.controller.auth.vo.auth.SysAuthMenuRespVO;
import cn.iocoder.dashboard.modules.system.controller.auth.vo.auth.SysAuthPermissionInfoRespVO;
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysMenuDO;
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysRoleDO;
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.user.SysUserDO;

View File

@ -0,0 +1,7 @@
package cn.iocoder.dashboard.modules.system.dal.mysql.dao.auth;
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.auth.SysUserSessionDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
public interface SysUserOnlineMapper extends BaseMapper<SysUserSessionDO> {
}

View File

@ -0,0 +1,38 @@
package cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.auth;
import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.user.SysUserDO;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 线
*/
@TableName(value = "sys_user_session", autoResultMap = true)
@Data
@EqualsAndHashCode(callSuper = true)
public class SysUserSessionDO extends BaseDO {
/**
* , sessionId
*/
@TableId
private String id;
/**
*
*
* {@link SysUserDO#getId()}
*/
private Long userId;
/**
* IP
*/
private String userIp;
/**
* UA
*/
private String userAgent;
}

View File

@ -0,0 +1,40 @@
package cn.iocoder.dashboard.modules.system.service.auth;
import cn.iocoder.dashboard.common.pojo.PageResult;
import cn.iocoder.dashboard.modules.system.controller.auth.vo.session.SysUserSessionPageReqVO;
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.auth.SysUserSessionDO;
import java.util.Date;
/**
* 线 Session Service
*/
public interface SysUserOnlineService {
/**
* 线 Session
*
* @param sessionId Session
* @param userId
* @param userIp IP
* @param userAgent UA
*/
void createUserOnline(String sessionId, Long userId, String userIp, String userAgent);
/**
* 线 Session
*
* @param sessionId Session
* @param updateTime
*/
void updateUserOnlineUpdateTime(String sessionId, Date updateTime);
/**
* 线
*
* @param reqVO
* @return
*/
PageResult<SysUserSessionDO> getUserSessionPage(SysUserSessionPageReqVO reqVO);
}