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 c3ea3ad7..2fb1bdc8 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 @@ -1,6 +1,8 @@ package com.ruoyi.web.controller.monitor; import java.util.List; + +import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -55,11 +57,19 @@ public class SysUserOnlineController extends BaseController return getDataTable(list); } - @RequiresPermissions("monitor:online:batchForceLogout") + /** + * 1、删除了 forceLogout 方法 + * 2、将 batchForceLogout 和 forceLogout 的权限逻辑 改成了 OR【按需要设定】 + * 3、@RequestParam("ids[]") ==> @RequestParam("ids") + * 4、开源拥有者 可以斟酌一下 + * @param ids + * @return + */ + @RequiresPermissions(value = {"monitor:online:batchForceLogout","monitor:online:forceLogout"},logical = Logical.OR) @Log(title = "在线用户", businessType = BusinessType.FORCE) @PostMapping("/batchForceLogout") @ResponseBody - public AjaxResult batchForceLogout(@RequestParam("ids[]") String[] ids) + public AjaxResult batchForceLogout(@RequestParam("ids") String[] ids) { for (String sessionId : ids) { @@ -84,31 +94,4 @@ public class SysUserOnlineController extends BaseController } return success(); } - - @RequiresPermissions("monitor:online:forceLogout") - @Log(title = "在线用户", businessType = BusinessType.FORCE) - @PostMapping("/forceLogout") - @ResponseBody - public AjaxResult forceLogout(String sessionId) - { - SysUserOnline online = userOnlineService.selectOnlineById(sessionId); - if (sessionId.equals(ShiroUtils.getSessionId())) - { - return error("当前登陆用户无法强退"); - } - if (online == null) - { - return error("用户已下线"); - } - OnlineSession onlineSession = (OnlineSession) onlineSessionDAO.readSession(online.getSessionId()); - if (onlineSession == null) - { - return error("用户已下线"); - } - onlineSession.setStatus(OnlineStatus.off_line); - onlineSessionDAO.update(onlineSession); - online.setStatus(OnlineStatus.off_line); - userOnlineService.saveOnline(online); - return success(); - } } diff --git a/ruoyi-admin/src/main/resources/templates/monitor/online/online.html b/ruoyi-admin/src/main/resources/templates/monitor/online/online.html index f69fcdb5..9d0068de 100644 --- a/ruoyi-admin/src/main/resources/templates/monitor/online/online.html +++ b/ruoyi-admin/src/main/resources/templates/monitor/online/online.html @@ -114,7 +114,9 @@ title: '操作', align: 'center', formatter: function(value, row, index) { - var msg = '强退 '; + // 传值改成 array 类型 + var ids = [row.sessionId] + var msg = '强退 '; return msg; } }] @@ -123,10 +125,11 @@ }); // 单条强退 + // 将该请求并到 batchForceLogout 中 function forceLogout(sessionId) { $.modal.confirm("确定要强制选中用户下线吗?", function() { - var data = { "sessionId": sessionId }; - $.operate.post(prefix + "/forceLogout", data); + var data = { "ids": sessionId }; + $.operate.post(prefix + "/batchForceLogout", data); }) }