✨ 新增剔出在线用户
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Infrastructure.Constant;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
using ZR.Admin.WebApi.Hubs;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System.Dto;
|
||||
using ZR.Service.System;
|
||||
|
||||
namespace ZR.Admin.WebApi.Controllers.monitor
|
||||
{
|
||||
@@ -12,9 +15,9 @@ namespace ZR.Admin.WebApi.Controllers.monitor
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysUserOnlineController : BaseController
|
||||
{
|
||||
private IHubContext<Hub> HubContext;
|
||||
private readonly IHubContext<MessageHub> HubContext;
|
||||
|
||||
public SysUserOnlineController(IHubContext<Hub> hubContext)
|
||||
public SysUserOnlineController(IHubContext<MessageHub> hubContext)
|
||||
{
|
||||
HubContext = hubContext;
|
||||
}
|
||||
@@ -33,5 +36,23 @@ namespace ZR.Admin.WebApi.Controllers.monitor
|
||||
|
||||
return SUCCESS(new { result, totalNum = MessageHub.clientUsers.Count });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 强退
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("lock")]
|
||||
[Log(Title = "强退", BusinessType = BusinessType.FORCE)]
|
||||
public async Task<IActionResult> Lock([FromBody] LockUserDto dto)
|
||||
{
|
||||
if (dto == null) { return ToResponse(ResultCode.PARAM_ERROR); }
|
||||
|
||||
await HubContext.Clients.Client(dto.ConnnectionId).SendAsync(HubsConstant.LockUser, new { dto.Reason, dto.Time });
|
||||
|
||||
var expirTime = DateTimeHelper.GetUnixTimeSeconds(DateTime.Now.AddMinutes(dto.Time));
|
||||
|
||||
CacheService.SetLockUser(dto.ClientId, expirTime, dto.Time);
|
||||
return SUCCESS(new { expirTime });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user