|
@@ -2,6 +2,7 @@ package com.ruoyi.web.controller.monitor;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
+import com.ruoyi.common.core.redis.RedisCache;
|
|
|
import com.ruoyi.framework.web.service.TokenService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
@@ -35,18 +36,18 @@ public class SysUserOnlineController extends BaseController {
|
|
|
@Autowired
|
|
|
private TokenService tokenService;
|
|
|
|
|
|
-// @Autowired
|
|
|
-// private RedisCache redisCache;
|
|
|
+ @Autowired
|
|
|
+ private RedisCache redisCache;
|
|
|
|
|
|
@PreAuthorize("@ss.hasPermi('monitor:online:list')")
|
|
|
@GetMapping("/list")
|
|
|
public TableDataInfo list(String ipaddr, String userName) {
|
|
|
-// Collection<String> keys = redisCache.keys(Constants.LOGIN_TOKEN_KEY + "*");
|
|
|
- Map<String, Object> keys = tokenService.getLoginUsers();
|
|
|
+ Collection<String> keys = redisCache.keys(Constants.LOGIN_TOKEN_KEY + "*");
|
|
|
+ //Map<String, Object> keys = tokenService.getLoginUsers();
|
|
|
List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();
|
|
|
- for (String key : keys.keySet()) {
|
|
|
- LoginUser user = (LoginUser) keys.get(key);
|
|
|
-// LoginUser user = redisCache.getCacheObject(key);
|
|
|
+ for (String key : keys) {
|
|
|
+ //LoginUser user = (LoginUser) keys.get(key);
|
|
|
+ LoginUser user = redisCache.getCacheObject(key);
|
|
|
if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) {
|
|
|
if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername())) {
|
|
|
userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user));
|
|
@@ -75,8 +76,8 @@ public class SysUserOnlineController extends BaseController {
|
|
|
@Log(title = "在线用户", businessType = BusinessType.FORCE)
|
|
|
@DeleteMapping("/{tokenId}")
|
|
|
public AjaxResult forceLogout(@PathVariable String tokenId) {
|
|
|
- tokenService.removeToken(Constants.LOGIN_TOKEN_KEY + tokenId);
|
|
|
-// redisCache.deleteObject(Constants.LOGIN_TOKEN_KEY + tokenId);
|
|
|
+ //tokenService.removeToken(Constants.LOGIN_TOKEN_KEY + tokenId);
|
|
|
+ redisCache.deleteObject(Constants.LOGIN_TOKEN_KEY + tokenId);
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
}
|