@Override public void updateLastOperTime(String token, Date date) { if (date == null) { Calendar c = Calendar.getInstance(); date = c.getTime(); } mapper.updateLastOperTime(token, date); }
@Override public JOnlineUsers getUserOnlines( Long userId, HttpServletRequest request, Boolean repeatLoginValidFlag) { // 1 web 2 android 3 winpad 客户端类型 int clientType = 1; // -----------排除超时 mapper.setTimeOut(); // 资源中心没有多级部署的情况: 使用注册站点作为登录站点 SRegister register = registerMapper.selectByPrimaryKey(userId); long registerNodeId = register.getNodeid(); // ---------------不允许重复登录时 if (!repeatLoginValidFlag) { mapper.clearRepeatUserLogin(userId, clientType, registerNodeId); } // token的有效时间 int validTime = ZhlOnlineUtil.getTokenValidTime(request); // 获取设备信息 String deviceInfo = ZhlOnlineUtil.getDeviceInfoWeb(request, userId, registerNodeId, clientType); // token 由UUID 生成 String token = UUID.randomUUID().toString(); // 从工具类中获取ip String loginIP = ZhlOnlineUtil.getIpAddr(request); Date currentDate = Calendar.getInstance().getTime(); JOnlineUsers user = new JOnlineUsers(); user.setUserid(userId); user.setClienttype(clientType); user.setClientversion(request.getHeader("user-agent")); user.setDeviceinfo(deviceInfo); user.setLoginip(loginIP); user.setLoginnodeid(registerNodeId); user.setLogintime(currentDate); user.setLastopertime(currentDate); user.setFlag(false); user.setStatus(ZhlOnlineUtil.ONLINE_STATUS_ONLINE); user.setToken(token); mapper.insert(user); return user; }
@Override public JOnlineUsers getUserOnlinesByToken(String token, Integer validTime) { JOnlineUsers obj = mapper.getOnlineByToken(token, validTime); if (obj == null) { throw new RuntimeException(CustomException.INVALIDACCESSTOKEN.getCode()); } return obj; }
@Override public void updateOnlineStatus(String token, Integer status) { mapper.updateOnlineStatus(token, status); }
@Override public void addUserOnline(JOnlineUsers user) { mapper.insert(user); }