|
@@ -1,9 +1,10 @@
|
|
|
package com.boman.system.controller;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Collection;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+import com.boman.common.core.utils.SecurityUtils;
|
|
|
+import com.boman.domain.SysUser;
|
|
|
+import com.boman.system.service.ISysUserService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
@@ -38,6 +39,24 @@ public class SysUserOnlineController extends BaseController
|
|
|
@Autowired
|
|
|
private RedisService redisService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService sysUserService;
|
|
|
+
|
|
|
+ @GetMapping("/onlineNum")
|
|
|
+ public AjaxResult onlineNum()
|
|
|
+ {
|
|
|
+ Collection<String> keys = redisService.keys(CacheConstants.LOGIN_TOKEN_KEY + "*");
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ int allCount = sysUserService.selectUserListAllCount();
|
|
|
+ map.put("onlineNum",keys.size());
|
|
|
+ map.put("allCount",allCount);
|
|
|
+ // 获取当前的用户信息
|
|
|
+ LoginUser user = redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + SecurityUtils.getToken());
|
|
|
+ Set<String> roles = user.getRoles();
|
|
|
+ map.put("roles",roles);
|
|
|
+ return AjaxResult.success(map);
|
|
|
+ }
|
|
|
+
|
|
|
@PreAuthorize(hasPermi = "monitor:online:list")
|
|
|
@GetMapping("/list")
|
|
|
public TableDataInfo list(String ipaddr, String userName)
|