Browse Source

feat: 调整IMessageManager

pull/148/head
zzzwangjun@gmail.com 1 year ago
parent
commit
1d987c6093
  1. 5
      aspnet-core/Lion.AbpPro.SignalR/Lion/AbpPro/SignalR/IMessageManager.cs
  2. 7
      aspnet-core/Lion.AbpPro.SignalR/Lion/AbpPro/SignalR/MessageManager.cs
  3. 14
      aspnet-core/modules/NotificationManagement/src/Lion.AbpPro.NotificationManagement.Application/Notifications/NotificationAppService.cs

5
aspnet-core/Lion.AbpPro.SignalR/Lion/AbpPro/SignalR/IMessageManager.cs

@ -9,9 +9,12 @@ public interface IMessageManager
/// <param name="content">消息内容</param>
/// <param name="messageType">消息类型</param>
/// <param name="messageLevel">消息级别</param>
/// <param name="senderUserId">消息发送人,如果是广播消息,不需要传递</param>
/// <param name="senderUserName">消息发送人userName</param>
/// <param name="receiverUserId">消息接受人,如果是广播消息,不需要传递</param>
/// <param name="receiverUserName">消息接受人userName,如果是广播消息,不需要传递</param>
/// <param name="tenantId">租户Id</param>
/// <param name="isPersistent">是否持久化,如果ture会在消息管理中出现,并且右上角也会存在</param>
/// <returns></returns>
Task SendMessageAsync(string title, string content, MessageType messageType, MessageLevel messageLevel, Guid? receiverUserId = null, string receiverUserName = "", bool isPersistent = true);
Task SendMessageAsync(string title, string content, MessageType messageType, MessageLevel messageLevel, Guid senderUserId, string senderUserName, Guid? receiverUserId = null, string receiverUserName = "", Guid? tenantId = null, bool isPersistent = true);
}

7
aspnet-core/Lion.AbpPro.SignalR/Lion/AbpPro/SignalR/MessageManager.cs

@ -29,11 +29,14 @@ public class MessageManager : IMessageManager, ITransientDependency
/// <param name="content">消息内容</param>
/// <param name="messageType">消息类型</param>
/// <param name="messageLevel">消息级别</param>
/// <param name="senderUserId">消息发送人,如果是广播消息,不需要传递</param>
/// <param name="senderUserName">消息发送人userName</param>
/// <param name="receiverUserId">消息接受人,如果是广播消息,不需要传递</param>
/// <param name="receiverUserName">消息接受人userName,如果是广播消息,不需要传递</param>
/// <param name="tenantId">租户Id</param>
/// <param name="isPersistent">是否持久化,如果ture会在消息管理中出现,并且右上角也会存在</param>
/// <returns></returns>
public virtual async Task SendMessageAsync(string title, string content, MessageType messageType, MessageLevel messageLevel, Guid? receiverUserId = null, string receiverUserName = "", bool isPersistent = true)
public virtual async Task SendMessageAsync(string title, string content, MessageType messageType, MessageLevel messageLevel, Guid senderUserId, string senderUserName, Guid? receiverUserId = null, string receiverUserName = "", Guid? tenantId = null, bool isPersistent = true)
{
var messageId = _guidGenerator.Create();
if (messageType == MessageType.Common)
@ -56,7 +59,7 @@ public class MessageManager : IMessageManager, ITransientDependency
if (isPersistent)
{
await _localEventBus.PublishAsync(new CreatedNotificationLocalEvent(messageId, _currentTenant.Id, title, content, messageType, messageLevel, _currentUser.GetId(), _currentUser.UserName, receiverUserId, receiverUserName, true));
await _localEventBus.PublishAsync(new CreatedNotificationLocalEvent(messageId, tenantId, title, content, messageType, messageLevel, senderUserId, senderUserName, receiverUserId, receiverUserName, true));
}
}
}

14
aspnet-core/modules/NotificationManagement/src/Lion.AbpPro.NotificationManagement.Application/Notifications/NotificationAppService.cs

@ -25,7 +25,7 @@ namespace Lion.AbpPro.NotificationManagement.Notifications
/// </summary>
public virtual async Task SendCommonWarningMessageAsync(SendCommonMessageInput input)
{
await _messageManager.SendMessageAsync(input.Title, input.Content, MessageType.Common, MessageLevel.Warning, input.ReceiveUserId, input.ReceiveUserName);
await _messageManager.SendMessageAsync(input.Title, input.Content, MessageType.Common, MessageLevel.Warning, CurrentUser.GetId(), CurrentUser.UserName, input.ReceiveUserId, input.ReceiveUserName, CurrentTenant.Id);
}
/// <summary>
@ -33,7 +33,7 @@ namespace Lion.AbpPro.NotificationManagement.Notifications
/// </summary>
public virtual async Task SendCommonInformationMessageAsync(SendCommonMessageInput input)
{
await _messageManager.SendMessageAsync(input.Title, input.Content, MessageType.Common, MessageLevel.Information, input.ReceiveUserId, input.ReceiveUserName);
await _messageManager.SendMessageAsync(input.Title, input.Content, MessageType.Common, MessageLevel.Information, CurrentUser.GetId(), CurrentUser.UserName, input.ReceiveUserId, input.ReceiveUserName, CurrentTenant.Id);
}
/// <summary>
@ -41,7 +41,7 @@ namespace Lion.AbpPro.NotificationManagement.Notifications
/// </summary>
public virtual async Task SendCommonErrorMessageAsync(SendCommonMessageInput input)
{
await _messageManager.SendMessageAsync(input.Title, input.Content, MessageType.Common, MessageLevel.Error, input.ReceiveUserId, input.ReceiveUserName);
await _messageManager.SendMessageAsync(input.Title, input.Content, MessageType.Common, MessageLevel.Error, CurrentUser.GetId(), CurrentUser.UserName, input.ReceiveUserId, input.ReceiveUserName, CurrentTenant.Id);
}
/// <summary>
@ -49,7 +49,7 @@ namespace Lion.AbpPro.NotificationManagement.Notifications
/// </summary>
public virtual async Task SendBroadCastWarningMessageAsync(SendBroadCastMessageInput input)
{
await _messageManager.SendMessageAsync(input.Title, input.Content, MessageType.BroadCast, MessageLevel.Warning);
await _messageManager.SendMessageAsync(input.Title, input.Content, MessageType.BroadCast, MessageLevel.Warning, CurrentUser.GetId(), CurrentUser.UserName, tenantId: CurrentTenant.Id);
}
/// <summary>
@ -57,7 +57,7 @@ namespace Lion.AbpPro.NotificationManagement.Notifications
/// </summary>
public virtual async Task SendBroadCastInformationMessageAsync(SendBroadCastMessageInput input)
{
await _messageManager.SendMessageAsync(input.Title, input.Content, MessageType.BroadCast, MessageLevel.Information);
await _messageManager.SendMessageAsync(input.Title, input.Content, MessageType.BroadCast, MessageLevel.Information, CurrentUser.GetId(), CurrentUser.UserName, tenantId: CurrentTenant.Id);
}
/// <summary>
@ -65,7 +65,7 @@ namespace Lion.AbpPro.NotificationManagement.Notifications
/// </summary>
public virtual async Task SendBroadCastErrorMessageAsync(SendBroadCastMessageInput input)
{
await _messageManager.SendMessageAsync(input.Title, input.Content, MessageType.BroadCast, MessageLevel.Error);
await _messageManager.SendMessageAsync(input.Title, input.Content, MessageType.BroadCast, MessageLevel.Error, CurrentUser.GetId(), CurrentUser.UserName, tenantId: CurrentTenant.Id);
}
public virtual async Task SetReadAsync(SetReadInput input)
@ -88,7 +88,7 @@ namespace Lion.AbpPro.NotificationManagement.Notifications
throw new AuthenticationException();
}
await _notificationSubscriptionManager.SetReadAsync(CurrentUser.Id.Value, CurrentUser.UserName, input.Id);
await _notificationSubscriptionManager.SetReadAsync(CurrentUser.GetId(), CurrentUser.UserName, input.Id);
}
}

Loading…
Cancel
Save