mirror of https://gitee.com/y_project/RuoYi.git
commit
8c88957b69
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,7 +114,9 @@
|
|||
title: '操作',
|
||||
align: 'center',
|
||||
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;
|
||||
}
|
||||
}]
|
||||
|
@ -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);
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue