优化设置、取消管理员
This commit is contained in:
parent
46eafbea8a
commit
09fbfae8b4
|
|
@ -60,21 +60,32 @@ namespace WGShare.API.Controllers.Frontend
|
|||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("manager")]
|
||||
public async Task SetRoomManager([FromQuery] string roomId, [FromQuery] string roomNum, [FromBody] string userId)
|
||||
public async Task SetRoomManager([FromBody] RoomManagerInputDTO inputDTO)
|
||||
{
|
||||
var user = RedisHelper.Instance.HGet<ChannelUserInfo>(RedisKeyConstant.SessionManage.GetChannelUserKey(TenantId, inputDTO.RoomNum), inputDTO.UserId);
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
throw Oops.Oh("用户已不在房间内!");
|
||||
}
|
||||
|
||||
var entities = new RoomManager
|
||||
{
|
||||
RoomId = roomId,
|
||||
UserId = userId
|
||||
RoomId = inputDTO.RoomId,
|
||||
UserId = inputDTO.UserId
|
||||
};
|
||||
|
||||
var user = RedisHelper.Instance.HGet<ChannelUserInfo>(RedisKeyConstant.SessionManage.GetChannelUserKey(TenantId, roomNum), userId);
|
||||
|
||||
user.IsRoomManager = true;
|
||||
|
||||
await _sqlSugar.Insertable(entities).ExecuteCommandAsync();
|
||||
RedisHelper.Instance.HSet(RedisKeyConstant.SessionManage.GetChannelUserKey(TenantId, roomNum), userId, user);
|
||||
await _sqlSugar.Storageable(entities)
|
||||
.SplitInsert(x => !x.Any())
|
||||
.ToStorage().AsInsertable.ExecuteCommandAsync();
|
||||
|
||||
await _hubContext.Clients.Group(roomNum).ManagerRefresh(user);
|
||||
//await _sqlSugar.Insertable(entities).ExecuteCommandAsync();
|
||||
RedisHelper.Instance.HSet(RedisKeyConstant.SessionManage.GetChannelUserKey(TenantId, inputDTO.RoomNum), inputDTO.UserId, user);
|
||||
|
||||
await _hubContext.Clients.Group(inputDTO.RoomNum).ManagerRefresh(user);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -82,17 +93,23 @@ namespace WGShare.API.Controllers.Frontend
|
|||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("manager")]
|
||||
public async Task DelRoomManager([FromQuery] string roomId, [FromQuery] string roomNum, [FromBody] string userId)
|
||||
public async Task DelRoomManager([FromBody] RoomManagerInputDTO inputDTO)
|
||||
{
|
||||
|
||||
var user = RedisHelper.Instance.HGet<ChannelUserInfo>(RedisKeyConstant.SessionManage.GetChannelUserKey(TenantId, inputDTO.RoomNum), inputDTO.UserId);
|
||||
if (user == null)
|
||||
{
|
||||
throw Oops.Oh("用户已不在房间内!");
|
||||
}
|
||||
|
||||
await _sqlSugar.Deleteable<RoomManager>()
|
||||
.Where(x => x.RoomId == roomId && x.UserId == userId)
|
||||
.Where(x => x.RoomId == inputDTO.RoomId && x.UserId == inputDTO.UserId)
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
var user = RedisHelper.Instance.HGet<ChannelUserInfo>(RedisKeyConstant.SessionManage.GetChannelUserKey(TenantId, roomNum), userId);
|
||||
user.IsRoomManager = false;
|
||||
RedisHelper.Instance.HSet(RedisKeyConstant.SessionManage.GetChannelUserKey(TenantId, roomNum), userId, user);
|
||||
RedisHelper.Instance.HSet(RedisKeyConstant.SessionManage.GetChannelUserKey(TenantId, inputDTO.RoomNum), inputDTO.UserId, user);
|
||||
|
||||
await _hubContext.Clients.Group(roomNum).ManagerRefresh(user);
|
||||
await _hubContext.Clients.Group(inputDTO.RoomNum).ManagerRefresh(user);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -263,6 +280,7 @@ namespace WGShare.API.Controllers.Frontend
|
|||
userInfo.EnableMicr = enableMicr;
|
||||
RedisHelper.Instance.HSet(RedisKeyConstant.SessionManage.GetChannelUserKey(TenantId, roomNum), uid, userInfo);
|
||||
|
||||
_logger.LogInformation($@"开闭麦克分,推送一次,roomNum:{roomNum},enableMicr:{enableMicr},uid:{uid}");
|
||||
// 通知所有人该用户麦克风状态
|
||||
await _hubContext.Clients.Group(roomNum).OperMicr(userInfo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,13 +97,13 @@
|
|||
会议室接口
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:WGShare.API.Controllers.Frontend.RoomController.SetRoomManager(System.String,System.String,System.String)">
|
||||
<member name="M:WGShare.API.Controllers.Frontend.RoomController.SetRoomManager(WGShare.Domain.DTOs.Room.RoomManagerInputDTO)">
|
||||
<summary>
|
||||
设置房间管理员
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WGShare.API.Controllers.Frontend.RoomController.DelRoomManager(System.String,System.String,System.String)">
|
||||
<member name="M:WGShare.API.Controllers.Frontend.RoomController.DelRoomManager(WGShare.Domain.DTOs.Room.RoomManagerInputDTO)">
|
||||
<summary>
|
||||
取消房间管理员
|
||||
</summary>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WGShare.Domain.DTOs.Room
|
||||
{
|
||||
public class RoomManagerInputDTO
|
||||
{
|
||||
public string RoomId { get; set; }
|
||||
public string RoomNum { get; set; }
|
||||
public string UserId { get; set; }
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue