This commit is contained in:
Putoo
2026-06-01 18:49:17 +08:00
parent 8a5b6d31ca
commit eb81a1c381
50 changed files with 1367 additions and 59 deletions

View File

@@ -214,4 +214,72 @@ public class ChatController : ControllerBase
return PoAction.Message("操作失败,请稍后尝试!");
}
}
/// <summary>
/// 封禁ID
/// </summary>
/// <param name="chatId"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> BlackUser(string chatId)
{
var chatInfo = await _chatService.GetChatInfo(chatId);
if (chatInfo == null)
{
return PoAction.Message("发言不存在!");
}
if (chatInfo.state != 1)
{
return PoAction.Message("发言不存在!");
}
if (chatInfo.areaId != StateHelper.areaId)
{
return PoAction.Message("发言不存在!");
}
if (chatInfo.userId == StateHelper.userId)
{
return PoAction.Message("不能封禁自己!");
}
bool IsOp = false;
string userId = StateHelper.userId;
int chatRole = await _userService.GetUserConfigInfo(userId, nameof(UserEnum.ConfigCode.ChatRole));
if ((chatInfo.code == nameof(GameChatEnum.Code.Public) || chatInfo.code == nameof(GameChatEnum.Code.Region)) &&
chatRole > 0)
{
IsOp = true;
}
else if (chatRole > 1 && chatInfo.code == nameof(GameChatEnum.Code.Dress))
{
IsOp = true;
}
if (IsOp == false)
{
return PoAction.Message("无权限!");
}
var otConfig = await _userService.GetUserConfigInfo(chatInfo.userId);
if (otConfig.chatRole < 0)
{
return PoAction.Message("Ta已被禁言,无需封禁!");
}
if (otConfig.chatRole != 0)
{
return PoAction.Message("您无权封禁!");
}
if (await _userService.UpdateUserConfigInfo(chatInfo.userId, nameof(UserEnum.ConfigCode.ChatRole), -1))
{
return PoAction.Ok(true);
}
else
{
return PoAction.Message("操作失败,请稍后尝试!");
}
}
}