Java Code Examples for com.ruoyi.system.domain.SysUserOnline

The following examples show how to use com.ruoyi.system.domain.SysUserOnline. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: supplierShop   Source File: AsyncFactory.java    License: MIT License 6 votes vote down vote up
/**
 * 同步session到数据库
 * 
 * @param session 在线用户会话
 * @return 任务task
 */
public static TimerTask syncSessionToDb(final OnlineSession session)
{
    return new TimerTask()
    {
        @Override
        public void run()
        {
            SysUserOnline online = new SysUserOnline();
            online.setSessionId(String.valueOf(session.getId()));
            online.setDeptName(session.getDeptName());
            online.setLoginName(session.getLoginName());
            online.setStartTimestamp(session.getStartTimestamp());
            online.setLastAccessTime(session.getLastAccessTime());
            online.setExpireTime(session.getTimeout());
            online.setIpaddr(session.getHost());
            online.setLoginLocation(AddressUtils.getRealAddressByIP(session.getHost()));
            online.setBrowser(session.getBrowser());
            online.setOs(session.getOs());
            online.setStatus(session.getStatus());
            SpringUtils.getBean(ISysUserOnlineService.class).saveOnline(online);

        }
    };
}
 
Example 2
Source Project: supplierShop   Source File: SysShiroService.java    License: MIT License 6 votes vote down vote up
public Session createSession(SysUserOnline userOnline)
{
    OnlineSession onlineSession = new OnlineSession();
    if (StringUtils.isNotNull(userOnline))
    {
        onlineSession.setId(userOnline.getSessionId());
        onlineSession.setHost(userOnline.getIpaddr());
        onlineSession.setBrowser(userOnline.getBrowser());
        onlineSession.setOs(userOnline.getOs());
        onlineSession.setDeptName(userOnline.getDeptName());
        onlineSession.setLoginName(userOnline.getLoginName());
        onlineSession.setStartTimestamp(userOnline.getStartTimestamp());
        onlineSession.setLastAccessTime(userOnline.getLastAccessTime());
        onlineSession.setTimeout(userOnline.getExpireTime());
    }
    return onlineSession;
}
 
Example 3
Source Project: supplierShop   Source File: SysUserOnlineController.java    License: MIT License 6 votes vote down vote up
@RequiresPermissions("monitor:online:forceLogout")
@Log(title = "在线用户", businessType = BusinessType.FORCE)
@PostMapping("/forceLogout")
@ResponseBody
public AjaxResult forceLogout(String sessionId)
{
    SysUserOnline online = userOnlineService.selectOnlineById(sessionId);
    if (sessionId.equals(ShiroUtils.getSessionId()))
    {
        return error("当前登陆用户无法强退");
    }
    if (online == null)
    {
        return error("用户已下线");
    }
    OnlineSession onlineSession = (OnlineSession) onlineSessionDAO.readSession(online.getSessionId());
    if (onlineSession == null)
    {
        return error("用户已下线");
    }
    onlineSession.setStatus(OnlineStatus.off_line);
    onlineSessionDAO.update(onlineSession);
    online.setStatus(OnlineStatus.off_line);
    userOnlineService.saveOnline(online);
    return success();
}
 
Example 4
Source Project: ruoyiplus   Source File: AsyncFactory.java    License: MIT License 6 votes vote down vote up
/**
 * 同步session到数据库
 * 
 * @param session 在线用户会话
 * @return 任务task
 */
public static TimerTask syncSessionToDb(final OnlineSession session)
{
    return new TimerTask()
    {
        @Override
        public void run()
        {
            SysUserOnline online = new SysUserOnline();
            online.setSessionId(String.valueOf(session.getId()));
            online.setDeptName(session.getDeptName());
            online.setLoginName(session.getLoginName());
            online.setStartTimestamp(session.getStartTimestamp());
            online.setLastAccessTime(session.getLastAccessTime());
            online.setExpireTime(session.getTimeout());
            online.setIpaddr(session.getHost());
            online.setLoginLocation(AddressUtils.getRealAddressByIP(session.getHost()));
            online.setBrowser(session.getBrowser());
            online.setOs(session.getOs());
            online.setStatus(session.getStatus());
            SpringUtils.getBean(ISysUserOnlineService.class).saveOnline(online);

        }
    };
}
 
Example 5
Source Project: ruoyiplus   Source File: SysShiroService.java    License: MIT License 6 votes vote down vote up
public Session createSession(SysUserOnline userOnline)
{
    OnlineSession onlineSession = new OnlineSession();
    if (StringUtils.isNotNull(userOnline))
    {
        onlineSession.setId(userOnline.getSessionId());
        onlineSession.setHost(userOnline.getIpaddr());
        onlineSession.setBrowser(userOnline.getBrowser());
        onlineSession.setOs(userOnline.getOs());
        onlineSession.setDeptName(userOnline.getDeptName());
        onlineSession.setLoginName(userOnline.getLoginName());
        onlineSession.setStartTimestamp(userOnline.getStartTimestamp());
        onlineSession.setLastAccessTime(userOnline.getLastAccessTime());
        onlineSession.setTimeout(userOnline.getExpireTime());
    }
    return onlineSession;
}
 
Example 6
Source Project: ruoyiplus   Source File: SysUserOnlineController.java    License: MIT License 6 votes vote down vote up
@RequiresPermissions("monitor:online:forceLogout")
@Log(title = "在线用户", businessType = BusinessType.FORCE)
@PostMapping("/forceLogout")
@ResponseBody
public AjaxResult forceLogout(String sessionId)
{
    SysUserOnline online = userOnlineService.selectOnlineById(sessionId);
    if (sessionId.equals(ShiroUtils.getSessionId()))
    {
        return error("当前登陆用户无法强退");
    }
    if (online == null)
    {
        return error("用户已下线");
    }
    OnlineSession onlineSession = (OnlineSession) onlineSessionDAO.readSession(online.getSessionId());
    if (onlineSession == null)
    {
        return error("用户已下线");
    }
    onlineSession.setStatus(OnlineStatus.off_line);
    online.setStatus(OnlineStatus.off_line);
    userOnlineService.saveOnline(online);
    return success();
}
 
Example 7
Source Project: RuoYi   Source File: AsyncFactory.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 同步session到数据库
 *
 * @param session 在线用户会话
 * @return 任务task
 */
public static TimerTask syncSessionToDb(final OnlineSession session) {
    return new TimerTask() {
        @Override
        public void run() {
            SysUserOnline online = new SysUserOnline();
            online.setSessionId(String.valueOf(session.getId()));
            online.setDeptName(session.getDeptName());
            online.setLoginName(session.getLoginName());
            online.setStartTimestamp(session.getStartTimestamp());
            online.setLastAccessTime(session.getLastAccessTime());
            online.setExpireTime(session.getTimeout());
            online.setIpaddr(session.getHost());
            online.setLoginLocation(AddressUtils.getRealAddressByIp(session.getHost()));
            online.setBrowser(session.getBrowser());
            online.setOs(session.getOs());
            online.setStatus(session.getStatus());
            SpringUtils.getBean(ISysUserOnlineService.class).saveOnline(online);

        }
    };
}
 
Example 8
Source Project: RuoYi   Source File: SysUserOnlineController.java    License: Apache License 2.0 6 votes vote down vote up
private String logout(String sessionId) {
    SysUserOnline online = userOnlineService.selectOnlineById(sessionId);
    if (sessionId.equals(ShiroUtils.getSessionId())) {
        return "当前登陆用户无法强退";
    }
    if (online == null) {
        return "用户已下线";
    }
    OnlineSession onlineSession = (OnlineSession) onlineSessionDAO.readSession(online.getSessionId());
    if (onlineSession == null) {
        return "用户已下线";
    }
    onlineSession.setStatus(OnlineStatus.OFF_LINE);
    online.setStatus(OnlineStatus.OFF_LINE);
    userOnlineService.saveOnline(online);
    return null;
}
 
Example 9
Source Project: supplierShop   Source File: SysUserOnlineServiceImpl.java    License: MIT License 5 votes vote down vote up
/**
 * 通过会话序号删除信息
 * 
 * @param sessionId 会话ID
 * @return 在线用户信息
 */
@Override
public void deleteOnlineById(String sessionId)
{
    SysUserOnline userOnline = selectOnlineById(sessionId);
    if (StringUtils.isNotNull(userOnline))
    {
        userOnlineDao.deleteOnlineById(sessionId);
    }
}
 
Example 10
Source Project: supplierShop   Source File: SysUserOnlineServiceImpl.java    License: MIT License 5 votes vote down vote up
/**
 * 通过会话序号删除信息
 * 
 * @param sessions 会话ID集合
 * @return 在线用户信息
 */
@Override
public void batchDeleteOnline(List<String> sessions)
{
    for (String sessionId : sessions)
    {
        SysUserOnline userOnline = selectOnlineById(sessionId);
        if (StringUtils.isNotNull(userOnline))
        {
            userOnlineDao.deleteOnlineById(sessionId);
        }
    }
}
 
Example 11
Source Project: supplierShop   Source File: SysUserOnlineServiceImpl.java    License: MIT License 5 votes vote down vote up
/**
 * 查询会话集合
 * 
 * @param expiredDate 失效日期
 */
@Override
public List<SysUserOnline> selectOnlineByExpired(Date expiredDate)
{
    String lastAccessTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, expiredDate);
    return userOnlineDao.selectOnlineByExpired(lastAccessTime);
}
 
Example 12
Source Project: supplierShop   Source File: SysUserOnlineController.java    License: MIT License 5 votes vote down vote up
@RequiresPermissions("monitor:online:batchForceLogout")
@Log(title = "在线用户", businessType = BusinessType.FORCE)
@PostMapping("/batchForceLogout")
@ResponseBody
public AjaxResult batchForceLogout(@RequestParam("ids[]") String[] ids)
{
    for (String sessionId : ids)
    {
        SysUserOnline online = userOnlineService.selectOnlineById(sessionId);
        if (online == null)
        {
            return error("用户已下线");
        }
        OnlineSession onlineSession = (OnlineSession) onlineSessionDAO.readSession(online.getSessionId());
        if (onlineSession == null)
        {
            return error("用户已下线");
        }
        if (sessionId.equals(ShiroUtils.getSessionId()))
        {
            return error("当前登陆用户无法强退");
        }
        onlineSession.setStatus(OnlineStatus.off_line);
        onlineSessionDAO.update(onlineSession);
        online.setStatus(OnlineStatus.off_line);
        userOnlineService.saveOnline(online);
    }
    return success();
}
 
Example 13
Source Project: ruoyiplus   Source File: SysUserOnlineServiceImpl.java    License: MIT License 5 votes vote down vote up
/**
 * 通过会话序号删除信息
 * 
 * @param sessionId 会话ID
 * @return 在线用户信息
 */
@Override
public void deleteOnlineById(String sessionId)
{
    SysUserOnline userOnline = selectOnlineById(sessionId);
    if (StringUtils.isNotNull(userOnline))
    {
        userOnlineDao.deleteOnlineById(sessionId);
    }
}
 
Example 14
Source Project: ruoyiplus   Source File: SysUserOnlineServiceImpl.java    License: MIT License 5 votes vote down vote up
/**
 * 通过会话序号删除信息
 * 
 * @param sessions 会话ID集合
 * @return 在线用户信息
 */
@Override
public void batchDeleteOnline(List<String> sessions)
{
    for (String sessionId : sessions)
    {
        SysUserOnline userOnline = selectOnlineById(sessionId);
        if (StringUtils.isNotNull(userOnline))
        {
            userOnlineDao.deleteOnlineById(sessionId);
        }
    }
}
 
Example 15
Source Project: ruoyiplus   Source File: SysUserOnlineServiceImpl.java    License: MIT License 5 votes vote down vote up
/**
 * 查询会话集合
 * 
 * @param expiredDate 失效日期
 */
@Override
public List<SysUserOnline> selectOnlineByExpired(Date expiredDate)
{
    String lastAccessTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, expiredDate);
    return userOnlineDao.selectOnlineByExpired(lastAccessTime);
}
 
Example 16
Source Project: ruoyiplus   Source File: SysUserOnlineController.java    License: MIT License 5 votes vote down vote up
@RequiresPermissions("monitor:online:batchForceLogout")
@Log(title = "在线用户", businessType = BusinessType.FORCE)
@PostMapping("/batchForceLogout")
@ResponseBody
public AjaxResult batchForceLogout(@RequestParam("ids[]") String[] ids)
{
    for (String sessionId : ids)
    {
        SysUserOnline online = userOnlineService.selectOnlineById(sessionId);
        if (online == null)
        {
            return error("用户已下线");
        }
        OnlineSession onlineSession = (OnlineSession) onlineSessionDAO.readSession(online.getSessionId());
        if (onlineSession == null)
        {
            return error("用户已下线");
        }
        if (sessionId.equals(ShiroUtils.getSessionId()))
        {
            return error("当前登陆用户无法强退");
        }
        onlineSession.setStatus(OnlineStatus.off_line);
        online.setStatus(OnlineStatus.off_line);
        userOnlineService.saveOnline(online);
    }
    return success();
}
 
Example 17
Source Project: RuoYi   Source File: SysShiroService.java    License: Apache License 2.0 5 votes vote down vote up
private Session createSession(SysUserOnline userOnline){
    OnlineSession onlineSession = new OnlineSession();
    if (ObjectUtil.isNotNull(userOnline)){
        onlineSession.setId(userOnline.getSessionId());
        onlineSession.setHost(userOnline.getIpaddr());
        onlineSession.setBrowser(userOnline.getBrowser());
        onlineSession.setOs(userOnline.getOs());
        onlineSession.setDeptName(userOnline.getDeptName());
        onlineSession.setLoginName(userOnline.getLoginName());
        onlineSession.setStartTimestamp(userOnline.getStartTimestamp());
        onlineSession.setLastAccessTime(userOnline.getLastAccessTime());
        onlineSession.setTimeout(userOnline.getExpireTime());
    }
    return onlineSession;
}
 
Example 18
Source Project: RuoYi   Source File: SysUserOnlineServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 通过会话序号删除信息
 *
 * @param sessionId 会话ID
 */
@Override
public void deleteOnlineById(String sessionId) {
    SysUserOnline userOnline = selectOnlineById(sessionId);
    if (ObjectUtil.isNotNull(userOnline)) {
        userOnlineDao.deleteOnlineById(sessionId);
    }
}
 
Example 19
Source Project: RuoYi   Source File: SysUserOnlineServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 通过会话序号删除信息
 *
 * @param sessions 会话ID集合
 */
@Override
public void batchDeleteOnline(List<String> sessions) {
    sessions.forEach(sessionId -> {
        SysUserOnline userOnline = selectOnlineById(sessionId);
        if (ObjectUtil.isNotNull(userOnline)) {
            userOnlineDao.deleteOnlineById(sessionId);
        }
    });
}
 
Example 20
Source Project: supplierShop   Source File: SysUserOnlineServiceImpl.java    License: MIT License 4 votes vote down vote up
/**
 * 保存会话信息
 * 
 * @param online 会话信息
 */
@Override
public void saveOnline(SysUserOnline online)
{
    userOnlineDao.saveOnline(online);
}
 
Example 21
Source Project: supplierShop   Source File: SysUserOnlineServiceImpl.java    License: MIT License 4 votes vote down vote up
/**
 * 查询会话集合
 * 
 * @param userOnline 在线用户
 */
@Override
public List<SysUserOnline> selectUserOnlineList(SysUserOnline userOnline)
{
    return userOnlineDao.selectUserOnlineList(userOnline);
}
 
Example 22
Source Project: ruoyiplus   Source File: SysUserOnlineServiceImpl.java    License: MIT License 4 votes vote down vote up
/**
 * 保存会话信息
 * 
 * @param online 会话信息
 */
@Override
public void saveOnline(SysUserOnline online)
{
    userOnlineDao.saveOnline(online);
}
 
Example 23
Source Project: ruoyiplus   Source File: SysUserOnlineServiceImpl.java    License: MIT License 4 votes vote down vote up
/**
 * 查询会话集合
 * 
 * @param userOnline 在线用户
 */
@Override
public List<SysUserOnline> selectUserOnlineList(SysUserOnline userOnline)
{
    return userOnlineDao.selectUserOnlineList(userOnline);
}
 
Example 24
Source Project: RuoYi   Source File: SysUserOnlineServiceImpl.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * 查询会话集合
 *
 * @param expiredDate 失效日期
 */
@Override
public List<SysUserOnline> selectOnlineByExpired(Date expiredDate) {
    String lastAccessTime = DateUtil.formatDateTime(expiredDate);
    return userOnlineDao.selectOnlineByExpired(lastAccessTime);
}
 
Example 25
Source Project: supplierShop   Source File: SysShiroService.java    License: MIT License 2 votes vote down vote up
/**
 * 获取会话信息
 *
 * @param sessionId
 * @return
 */
public Session getSession(Serializable sessionId)
{
    SysUserOnline userOnline = onlineService.selectOnlineById(String.valueOf(sessionId));
    return StringUtils.isNull(userOnline) ? null : createSession(userOnline);
}
 
Example 26
Source Project: supplierShop   Source File: ISysUserOnlineService.java    License: MIT License 2 votes vote down vote up
/**
 * 通过会话序号查询信息
 * 
 * @param sessionId 会话ID
 * @return 在线用户信息
 */
public SysUserOnline selectOnlineById(String sessionId);
 
Example 27
Source Project: supplierShop   Source File: ISysUserOnlineService.java    License: MIT License 2 votes vote down vote up
/**
 * 保存会话信息
 * 
 * @param online 会话信息
 */
public void saveOnline(SysUserOnline online);
 
Example 28
Source Project: supplierShop   Source File: ISysUserOnlineService.java    License: MIT License 2 votes vote down vote up
/**
 * 查询会话集合
 * 
 * @param userOnline 分页参数
 * @return 会话集合
 */
public List<SysUserOnline> selectUserOnlineList(SysUserOnline userOnline);
 
Example 29
Source Project: supplierShop   Source File: ISysUserOnlineService.java    License: MIT License 2 votes vote down vote up
/**
 * 查询会话集合
 * 
 * @param expiredDate 有效期
 * @return 会话集合
 */
public List<SysUserOnline> selectOnlineByExpired(Date expiredDate);
 
Example 30
Source Project: supplierShop   Source File: SysUserOnlineServiceImpl.java    License: MIT License 2 votes vote down vote up
/**
 * 通过会话序号查询信息
 * 
 * @param sessionId 会话ID
 * @return 在线用户信息
 */
@Override
public SysUserOnline selectOnlineById(String sessionId)
{
    return userOnlineDao.selectOnlineById(sessionId);
}