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(); }