mirror of https://gitee.com/y_project/RuoYi.git
用户在线监测 部分修改建议
parent
30b3909fc4
commit
bb9d504d40
|
@ -1,6 +1,8 @@
|
||||||
package com.ruoyi.web.controller.monitor;
|
package com.ruoyi.web.controller.monitor;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.shiro.authz.annotation.Logical;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
@ -55,11 +57,19 @@ public class SysUserOnlineController extends BaseController
|
||||||
return getDataTable(list);
|
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)
|
@Log(title = "在线用户", businessType = BusinessType.FORCE)
|
||||||
@PostMapping("/batchForceLogout")
|
@PostMapping("/batchForceLogout")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult batchForceLogout(@RequestParam("ids[]") String[] ids)
|
public AjaxResult batchForceLogout(@RequestParam("ids") String[] ids)
|
||||||
{
|
{
|
||||||
for (String sessionId : ids)
|
for (String sessionId : ids)
|
||||||
{
|
{
|
||||||
|
@ -84,31 +94,4 @@ public class SysUserOnlineController extends BaseController
|
||||||
}
|
}
|
||||||
return success();
|
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,9 @@
|
||||||
title: '操作',
|
title: '操作',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
formatter: function(value, row, index) {
|
formatter: function(value, row, index) {
|
||||||
var msg = '<a class="btn btn-danger btn-xs ' + forceFlag + '" href="javascript:void(0)" onclick="forceLogout(\'' + row.sessionId + '\')"><i class="fa fa-sign-out"></i>强退</a> ';
|
// 传值改成 array 类型
|
||||||
|
var ids = [row.sessionId]
|
||||||
|
var msg = '<a class="btn btn-danger btn-xs ' + forceFlag + '" href="javascript:void(0)" onclick="forceLogout(\'' + ids + '\')"><i class="fa fa-sign-out"></i>强退</a> ';
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
|
@ -123,10 +125,11 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
// 单条强退
|
// 单条强退
|
||||||
|
// 将该请求并到 batchForceLogout 中
|
||||||
function forceLogout(sessionId) {
|
function forceLogout(sessionId) {
|
||||||
$.modal.confirm("确定要强制选中用户下线吗?", function() {
|
$.modal.confirm("确定要强制选中用户下线吗?", function() {
|
||||||
var data = { "sessionId": sessionId };
|
var data = { "ids": sessionId };
|
||||||
$.operate.post(prefix + "/forceLogout", data);
|
$.operate.post(prefix + "/batchForceLogout", data);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue