Java Code Examples for com.ruoyi.system.domain.SysUserOnline#setStatus()

The following examples show how to use com.ruoyi.system.domain.SysUserOnline#setStatus() . 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   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   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 3
Source Project: ruoyiplus   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 4
Source Project: ruoyiplus   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 5
Source Project: RuoYi   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 6
Source Project: RuoYi   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 7
Source Project: supplierShop   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 8
Source Project: ruoyiplus   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();
}