From 16fcd9d44b6dd7fb4405cbe40f65784145d2e66a Mon Sep 17 00:00:00 2001 From: D <3066417822@qq.com> Date: Sat, 13 Jan 2024 14:10:22 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=8D=87=E7=BA=A7springboot3?= =?UTF-8?q?.2.x=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../monitor/SysUserOnlineController.java | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java index ee90fe0..b8afdbd 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java @@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.annotation.Log; @@ -32,8 +33,7 @@ import com.ruoyi.system.service.ISysUserOnlineService; */ @RestController @RequestMapping("/monitor/online") -public class SysUserOnlineController extends BaseController -{ +public class SysUserOnlineController extends BaseController { @Autowired private ISysUserOnlineService userOnlineService; @@ -42,27 +42,19 @@ public class SysUserOnlineController extends BaseController @PreAuthorize("@ss.hasPermi('monitor:online:list')") @GetMapping("/list") - public TableDataInfo list(String ipaddr, String userName) - { + public TableDataInfo list(@RequestParam(name = "ipaddr", required = false) String ipaddr, + @RequestParam(name = "userName", required = false) String userName) { Collection keys = redisCache.keys(CacheConstants.LOGIN_TOKEN_KEY + "*"); List userOnlineList = new ArrayList(); - for (String key : keys) - { + for (String key : keys) { LoginUser user = redisCache.getCacheObject(key); - if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) - { + if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) { userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user)); - } - else if (StringUtils.isNotEmpty(ipaddr)) - { + } else if (StringUtils.isNotEmpty(ipaddr)) { userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user)); - } - else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser())) - { + } else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser())) { userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user)); - } - else - { + } else { userOnlineList.add(userOnlineService.loginUserToUserOnline(user)); } } @@ -77,8 +69,7 @@ public class SysUserOnlineController extends BaseController @PreAuthorize("@ss.hasPermi('monitor:online:forceLogout')") @Log(title = "在线用户", businessType = BusinessType.FORCE) @DeleteMapping("/{tokenId}") - public AjaxResult forceLogout(@PathVariable( name = "tokenId" ) String tokenId) - { + public AjaxResult forceLogout(@PathVariable(name = "tokenId") String tokenId) { redisCache.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId); return success(); }