diff --git a/WGShare.API/Controllers/Frontend/RoomController.cs b/WGShare.API/Controllers/Frontend/RoomController.cs
index 5e70848..a56ddf7 100644
--- a/WGShare.API/Controllers/Frontend/RoomController.cs
+++ b/WGShare.API/Controllers/Frontend/RoomController.cs
@@ -60,21 +60,32 @@ namespace WGShare.API.Controllers.Frontend
///
///
[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(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(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);
}
///
@@ -82,17 +93,23 @@ namespace WGShare.API.Controllers.Frontend
///
///
[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(RedisKeyConstant.SessionManage.GetChannelUserKey(TenantId, inputDTO.RoomNum), inputDTO.UserId);
+ if (user == null)
+ {
+ throw Oops.Oh("用户已不在房间内!");
+ }
+
await _sqlSugar.Deleteable()
- .Where(x => x.RoomId == roomId && x.UserId == userId)
+ .Where(x => x.RoomId == inputDTO.RoomId && x.UserId == inputDTO.UserId)
.ExecuteCommandAsync();
- var user = RedisHelper.Instance.HGet(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);
}
///
@@ -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);
}
diff --git a/WGShare.API/WGShare.API.xml b/WGShare.API/WGShare.API.xml
index a7bc114..bb69696 100644
--- a/WGShare.API/WGShare.API.xml
+++ b/WGShare.API/WGShare.API.xml
@@ -97,13 +97,13 @@
会议室接口
-
+
设置房间管理员
-
+
取消房间管理员
diff --git a/WGShare.Domain/DTOs/Room/RoomManagerInputDTO.cs b/WGShare.Domain/DTOs/Room/RoomManagerInputDTO.cs
new file mode 100644
index 0000000..07472ca
--- /dev/null
+++ b/WGShare.Domain/DTOs/Room/RoomManagerInputDTO.cs
@@ -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; }
+ }
+}