用户在线监测 部分修改建议

dep_wangsr
JoseK43326 5 years ago committed by Limy
parent bd6c37456e
commit 5ad3292260

@ -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…
Cancel
Save