Browse Source

Merge pull request #379 from colinin/4.4.1

redesign some communication apis
pull/396/head
yx lin 4 years ago
committed by GitHub
parent
commit
27b3711276
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/AbpIMSignalRModule.cs
  2. 5
      aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/AbpIMSignalROptions.cs
  3. 121
      aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/Hubs/MessagesHub.cs
  4. 6
      aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/Localization/Resources/en.json
  5. 6
      aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/Localization/Resources/zh-Hans.json
  6. 83
      aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/Messages/SignalRMessageSenderProvider.cs
  7. 22
      aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/AbpIMModule.cs
  8. 1
      aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Contract/IFriendStore.cs
  9. 9
      aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Localization/AbpIMResource.cs
  10. 5
      aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Localization/Resources/en.json
  11. 5
      aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Localization/Resources/zh-Hans.json
  12. 180
      aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Messages/ChatMessage.cs
  13. 64
      aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Messages/LastChatMessage.cs
  14. 8
      aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Messages/MessageSourceTye.cs
  15. 2
      aspnet-core/modules/common/LINGYUN.Abp.Notifications.SignalR/LINGYUN/Abp/Notifications/SignalR/AbpNotificationsSignalRModule.cs
  16. 10
      aspnet-core/modules/common/LINGYUN.Abp.Notifications.SignalR/LINGYUN/Abp/Notifications/SignalR/NotificationDataExtensions.cs
  17. 55
      aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NotificationData.cs
  18. 9
      aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NotificationDataConverter.cs
  19. 2
      aspnet-core/modules/common/LINGYUN.Abp.RealTime/LINGYUN/Abp/RealTime/Localization/LocalizableStringInfo.cs
  20. 5
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Chat/MyFriendAppService.cs
  21. 2
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/FriendStore.cs
  22. 19
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/Message.cs
  23. 8
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/MessageProcessor.cs
  24. 21
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/MessageStore.cs
  25. 4
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/UserChatFriend.cs
  26. 17
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/UserMessage.cs
  27. 47
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/UserOnlineChanger.cs
  28. 1
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/EventBus/Local/UserChatFriendEventHandler.cs
  29. 16
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/GroupMessage.cs
  30. 4
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/UserGroupStore.cs
  31. 53
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/MessageServiceDomainAutoMapperProfile.cs
  32. 7
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/NotificationTypeConverter.cs
  33. 33
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/Notification.cs
  34. 40
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationStore.cs
  35. 307
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreMessageRepository.cs
  36. 2
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContextModelCreatingExtensions.cs
  37. 3
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreUserNotificationRepository.cs
  38. 6
      aspnet-core/modules/wechat/LINGYUN.Abp.Notifications.WeChat.MiniProgram/LINGYUN/Abp/Notifications/WeChat/MiniProgram/WeChatMiniProgramNotificationPublishProvider.cs
  39. 5
      aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/AbpMessageServiceHttpApiHostModule.cs
  40. 3
      aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/EventBus/Distributed/TenantSynchronizer.cs
  41. 2
      aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/EventBus/Local/UserCreateJoinIMEventHandler.cs
  42. 1
      aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/EventBus/Local/UserCreateSendWelcomeEventHandler.cs
  43. 621
      aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/Migrations/20211111014501_Add-Base-Type-ExtraProp-To-Notification.Designer.cs
  44. 36
      aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/Migrations/20211111014501_Add-Base-Type-ExtraProp-To-Notification.cs
  45. 627
      aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/Migrations/20211111080938_Add-Source-Type-To-Chat-Message.Designer.cs
  46. 35
      aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/Migrations/20211111080938_Add-Source-Type-To-Chat-Message.cs
  47. 630
      aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/Migrations/20211111221335_Add-Field-Static-To-Chat-Friend.Designer.cs
  48. 24
      aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/Migrations/20211111221335_Add-Field-Static-To-Chat-Friend.cs
  49. 630
      aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/Migrations/20211112083050_Rename-Field-SendState-To-State.Designer.cs
  50. 33
      aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/Migrations/20211112083050_Rename-Field-SendState-To-State.cs
  51. 866
      aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/Migrations/MessageServiceHostMigrationsDbContextModelSnapshot.cs
  52. 4
      aspnet-core/tests/LINGYUN.Abp.Notifications.Sms.Tests/LINGYUN/Abp/Notifications/Sms/SmsNotificationDataMapping_Tests.cs
  53. 4
      aspnet-core/tests/LINGYUN.Abp.Notifications.WeChat.MiniProgram.Tests/LINGYUN/Abp/Notifications/WeChat/WeChatMiniProgramNotificationDataMapping_Tests.cs

15
aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/AbpIMSignalRModule.cs

@ -1,7 +1,10 @@
using LINGYUN.Abp.AspNetCore.SignalR.JwtToken;
using LINGYUN.Abp.IM.Localization;
using LINGYUN.Abp.IM.SignalR.Messages;
using LINGYUN.Abp.RealTime.SignalR;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.VirtualFileSystem;
namespace LINGYUN.Abp.IM.SignalR
{
@ -18,6 +21,18 @@ namespace LINGYUN.Abp.IM.SignalR
options.Providers.Add<SignalRMessageSenderProvider>();
});
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<AbpIMSignalRModule>();
});
Configure<AbpLocalizationOptions>(options =>
{
options.Resources
.Get<AbpIMResource>()
.AddVirtualJson("/LINGYUN/Abp/IM/SignalR/Localization/Resources");
});
Configure<AbpAspNetCoreSignalRJwtTokenMapPathOptions>(options =>
{
options.MapPath("messages");

5
aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/AbpIMSignalROptions.cs

@ -7,6 +7,10 @@
/// </summary>
public string GetChatMessageMethod { get; set; }
/// <summary>
/// 自定义的客户端撤回消息方法名称
/// </summary>
public string ReCallChatMessageMethod { get; set; }
/// <summary>
/// 用户上线接收方法名称
/// </summary>
public string UserOnlineMethod { get; set; }
@ -18,6 +22,7 @@
public AbpIMSignalROptions()
{
GetChatMessageMethod = "get-chat-message";
ReCallChatMessageMethod = "recall-chat-message";
UserOnlineMethod = "on-user-onlined";
UserOfflineMethod = "on-user-offlined";
}

121
aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/Hubs/MessagesHub.cs

@ -1,16 +1,24 @@
using LINGYUN.Abp.IM.Contract;
using LINGYUN.Abp.IM.Groups;
using LINGYUN.Abp.IM.Localization;
using LINGYUN.Abp.IM.Messages;
using LINGYUN.Abp.RealTime;
using LINGYUN.Abp.RealTime.Client;
using LINGYUN.Abp.RealTime.Localization;
using LINGYUN.Abp.RealTime.SignalR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.AspNetCore.ExceptionHandling;
using Volo.Abp.Data;
using Volo.Abp.Localization;
namespace LINGYUN.Abp.IM.SignalR.Hubs
{
@ -21,6 +29,10 @@ namespace LINGYUN.Abp.IM.SignalR.Hubs
protected IUserOnlineChanger OnlineChanger => LazyServiceProvider.LazyGetService<IUserOnlineChanger>();
protected ISnowflakeIdrGenerator SnowflakeIdrGenerator => LazyServiceProvider.LazyGetService<ISnowflakeIdrGenerator>();
protected IExceptionToErrorInfoConverter ErrorInfoConverter => LazyServiceProvider.LazyGetService<IExceptionToErrorInfoConverter>();
protected AbpIMSignalROptions Options { get; }
protected IFriendStore FriendStore { get; }
protected IMessageStore MessageStore { get; }
@ -98,32 +110,113 @@ namespace LINGYUN.Abp.IM.SignalR.Hubs
[HubMethodName("send")]
public virtual async Task SendAsync(ChatMessage chatMessage)
{
// 持久化
await MessageStore.StoreMessageAsync(chatMessage, cancellationToken: Context.ConnectionAborted);
await SendMessageAsync(Options.GetChatMessageMethod, chatMessage, true);
}
[HubMethodName("recall")]
public virtual async Task ReCallAsync(ChatMessage chatMessage)
{
await Processor.ReCallAsync(chatMessage);
if (!chatMessage.GroupId.IsNullOrWhiteSpace())
{
await SendMessageToGroupAsync(chatMessage);
await SendMessageAsync(
Options.ReCallChatMessageMethod,
ChatMessage.SystemLocalized(
chatMessage.FormUserId,
chatMessage.GroupId,
new LocalizableStringInfo(
LocalizationResourceNameAttribute.GetName(typeof(AbpIMResource)),
"Messages:RecallMessage",
new Dictionary<object, object>
{
{ "User", chatMessage.FormUserName }
}),
Clock,
chatMessage.MessageType,
chatMessage.TenantId)
.SetProperty(nameof(ChatMessage.MessageId).ToPascalCase(), chatMessage.MessageId),
callbackException: false);
}
else
{
await SendMessageToUserAsync(chatMessage);
await SendMessageAsync(
Options.ReCallChatMessageMethod,
ChatMessage.SystemLocalized(
chatMessage.ToUserId.Value,
chatMessage.FormUserId,
new LocalizableStringInfo(
LocalizationResourceNameAttribute.GetName(typeof(AbpIMResource)),
"Messages:RecallMessage",
new Dictionary<object, object>
{
{ "User", chatMessage.FormUserName }
}),
Clock,
chatMessage.MessageType,
chatMessage.TenantId)
.SetProperty(nameof(ChatMessage.MessageId).ToPascalCase(), chatMessage.MessageId),
callbackException: false);
}
}
[HubMethodName("recall")]
public virtual async Task ReCallAsync(ChatMessage chatMessage)
{
await Processor.ReCallAsync(chatMessage);
}
[HubMethodName("read")]
public virtual async Task ReadAsync(ChatMessage chatMessage)
{
await Processor.ReadAsync(chatMessage);
}
protected virtual async Task SendMessageToGroupAsync(ChatMessage chatMessage)
protected virtual async Task SendMessageAsync(string methodName, ChatMessage chatMessage, bool callbackException = false)
{
// 持久化
try
{
chatMessage.SetProperty(nameof(ChatMessage.IsAnonymous), chatMessage.IsAnonymous);
chatMessage.MessageId = SnowflakeIdrGenerator.Create().ToString();
await MessageStore.StoreMessageAsync(chatMessage);
if (!chatMessage.GroupId.IsNullOrWhiteSpace())
{
await SendMessageToGroupAsync(methodName, chatMessage);
}
else
{
await SendMessageToUserAsync(methodName, chatMessage);
}
}
catch (Exception ex)
{
if (callbackException && ex is IBusinessException)
{
var errorInfo = ErrorInfoConverter.Convert(ex, false);
if (!chatMessage.GroupId.IsNullOrWhiteSpace())
{
await SendMessageToGroupAsync(
methodName,
ChatMessage.System(
chatMessage.FormUserId,
chatMessage.GroupId,
errorInfo.Message,
Clock,
chatMessage.MessageType,
chatMessage.TenantId));
}
else
{
await SendMessageToUserAsync(
methodName,
ChatMessage.System(
chatMessage.ToUserId.Value,
chatMessage.FormUserId,
errorInfo.Message,
Clock,
chatMessage.MessageType,
chatMessage.TenantId));
}
}
}
}
protected virtual async Task SendMessageToGroupAsync(string methodName, ChatMessage chatMessage)
{
var signalRClient = Clients.Group(chatMessage.GroupId);
if (signalRClient == null)
@ -132,10 +225,10 @@ namespace LINGYUN.Abp.IM.SignalR.Hubs
return;
}
await signalRClient.SendAsync(Options.GetChatMessageMethod, chatMessage, cancellationToken: Context.ConnectionAborted);
await signalRClient.SendAsync(methodName, chatMessage);
}
protected virtual async Task SendMessageToUserAsync(ChatMessage chatMessage)
protected virtual async Task SendMessageToUserAsync(string methodName, ChatMessage chatMessage)
{
var onlineClientContext = new OnlineClientContext(chatMessage.TenantId, chatMessage.ToUserId.GetValueOrDefault());
var onlineClients = OnlineClientManager.GetAllByContext(onlineClientContext);
@ -150,7 +243,7 @@ namespace LINGYUN.Abp.IM.SignalR.Hubs
Logger.LogDebug("Can not get user " + onlineClientContext.UserId + " with connectionId " + onlineClient.ConnectionId + " from SignalR hub!");
continue;
}
await signalRClient.SendAsync(Options.GetChatMessageMethod, chatMessage, cancellationToken: Context.ConnectionAborted);
await signalRClient.SendAsync(methodName, chatMessage);
}
catch (Exception ex)
{

6
aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/Localization/Resources/en.json

@ -0,0 +1,6 @@
{
"culture": "en",
"texts": {
"Messages:RecallMessage": "{User} cancel a message"
}
}

6
aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/Localization/Resources/zh-Hans.json

@ -0,0 +1,6 @@
{
"culture": "zh-Hans",
"texts": {
"Messages:RecallMessage": "{User} 撤回了一条消息"
}
}

83
aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/Messages/SignalRMessageSenderProvider.cs

@ -8,7 +8,11 @@ using System;
using System.Collections.Immutable;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.AspNetCore.ExceptionHandling;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Timing;
namespace LINGYUN.Abp.IM.SignalR.Messages
{
@ -35,17 +39,40 @@ namespace LINGYUN.Abp.IM.SignalR.Messages
protected override async Task SendMessageToGroupAsync(ChatMessage chatMessage)
{
var signalRClient = _hubContext.Clients.Group(chatMessage.GroupId);
if (signalRClient == null)
await TrySendMessageToGroupAsync(chatMessage, true);
}
protected override async Task SendMessageToUserAsync(ChatMessage chatMessage)
{
await TrySendMessageToUserAsync(chatMessage, true);
}
protected virtual async Task TrySendMessageToGroupAsync(ChatMessage chatMessage, bool sendingExceptionCallback = true)
{
try
{
Logger.LogDebug("Can not get group " + chatMessage.GroupId + " from SignalR hub!");
return;
var signalRClient = _hubContext.Clients.Group(chatMessage.GroupId);
if (signalRClient == null)
{
Logger.LogDebug("Can not get group " + chatMessage.GroupId + " from SignalR hub!");
return;
}
await signalRClient.SendAsync(_options.GetChatMessageMethod, chatMessage);
}
catch (Exception ex)
{
Logger.LogWarning("Could not send message to group: {0}", chatMessage.GroupId);
Logger.LogWarning("Send to group message error: {0}", ex.Message);
await signalRClient.SendAsync(_options.GetChatMessageMethod, chatMessage);
if (sendingExceptionCallback)
{
await TrySendBusinessErrorMessage(ex, chatMessage);
}
}
}
protected override async Task SendMessageToUserAsync(ChatMessage chatMessage)
protected virtual async Task TrySendMessageToUserAsync(ChatMessage chatMessage, bool sendingExceptionCallback = true)
{
try
{
@ -65,6 +92,50 @@ namespace LINGYUN.Abp.IM.SignalR.Messages
{
Logger.LogWarning("Could not send message to user: {0}", chatMessage.ToUserId);
Logger.LogWarning("Send to user message error: {0}", ex.Message);
if (sendingExceptionCallback)
{
await TrySendBusinessErrorMessage(ex, chatMessage);
}
}
}
protected virtual async Task TrySendBusinessErrorMessage(Exception ex, ChatMessage chatMessage)
{
if (ex is IBusinessException)
{
var clock = ServiceProvider.LazyGetRequiredService<IClock>();
var errorInfoConverter = ServiceProvider.LazyGetService<IExceptionToErrorInfoConverter>();
if (errorInfoConverter != null)
{
var errorInfo = errorInfoConverter.Convert(ex, false);
if (!chatMessage.GroupId.IsNullOrWhiteSpace())
{
await TrySendMessageToGroupAsync(
ChatMessage.System(
chatMessage.FormUserId,
chatMessage.GroupId,
errorInfo.Message,
clock,
chatMessage.MessageType,
chatMessage.TenantId)
.SetProperty(nameof(ChatMessage.MessageId).ToPascalCase(), chatMessage.MessageId),
sendingExceptionCallback: false);
}
else
{
await TrySendMessageToUserAsync(
ChatMessage.System(
chatMessage.FormUserId,
chatMessage.ToUserId.Value,
errorInfo.Message,
clock,
chatMessage.MessageType,
chatMessage.TenantId)
.SetProperty(nameof(ChatMessage.MessageId).ToPascalCase(), chatMessage.MessageId),
sendingExceptionCallback: false);
}
}
}
}
}

22
aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/AbpIMModule.cs

@ -1,13 +1,31 @@
using LINGYUN.Abp.RealTime;
using LINGYUN.Abp.IM.Localization;
using LINGYUN.Abp.RealTime;
using Volo.Abp.EventBus;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.VirtualFileSystem;
namespace LINGYUN.Abp.IM
{
[DependsOn(
typeof(AbpEventBusModule),
typeof(AbpRealTimeModule))]
typeof(AbpRealTimeModule),
typeof(AbpLocalizationModule))]
public class AbpIMModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<AbpIMModule>();
});
Configure<AbpLocalizationOptions>(options =>
{
options.Resources
.Add<AbpIMResource>()
.AddVirtualJson("/LINGYUN/Abp/IM/Localization/Resources");
});
}
}
}

1
aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Contract/IFriendStore.cs

@ -101,6 +101,7 @@ namespace LINGYUN.Abp.IM.Contract
Guid userId,
Guid friendId,
string remarkName = "",
bool isStatic = false,
CancellationToken cancellationToken = default);
/// <summary>
/// 添加好友请求

9
aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Localization/AbpIMResource.cs

@ -0,0 +1,9 @@
using Volo.Abp.Localization;
namespace LINGYUN.Abp.IM.Localization
{
[LocalizationResourceName("AbpIM")]
public class AbpIMResource
{
}
}

5
aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Localization/Resources/en.json

@ -0,0 +1,5 @@
{
"culture": "en",
"texts": {
}
}

5
aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Localization/Resources/zh-Hans.json

@ -0,0 +1,5 @@
{
"culture": "zh-Hans",
"texts": {
}
}

180
aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Messages/ChatMessage.cs

@ -1,15 +1,15 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using LINGYUN.Abp.RealTime.Localization;
using System;
using Volo.Abp.Auditing;
using Volo.Abp.Data;
using Volo.Abp.EventBus;
using Volo.Abp.ObjectExtending;
using Volo.Abp.Timing;
namespace LINGYUN.Abp.IM.Messages
{
[Serializable]
[EventName("im.message")]
public class ChatMessage : ExtensibleObject
public class ChatMessage : IHasExtraProperties
{
/// <summary>
/// 租户
@ -59,24 +59,178 @@ namespace LINGYUN.Abp.IM.Messages
/// </summary>
public MessageType MessageType { get; set; } = MessageType.Text;
public override IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
public MessageSourceTye Source { get; set; } = MessageSourceTye.User;
public ExtraPropertyDictionary ExtraProperties { get; set; }
public ChatMessage()
{
var results = ExtensibleObjectValidator.GetValidationErrors(this, validationContext);
ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties();
}
foreach (var result in ValidateReceiver(validationContext))
public static ChatMessage User(
Guid formUserId,
string formUserName,
Guid toUserId,
string content,
IClock clock,
bool isAnonymous = false,
MessageType type = MessageType.Text,
MessageSourceTye souce = MessageSourceTye.User,
Guid? tenantId = null)
{
return new ChatMessage
{
FormUserId = formUserId,
FormUserName = formUserName,
ToUserId = toUserId,
Content = content,
SendTime = clock.Now,
IsAnonymous = isAnonymous,
MessageType = type,
TenantId = tenantId,
Source = souce,
};
}
public static ChatMessage System(
Guid formUserId,
Guid toUserId,
string content,
IClock clock,
MessageType type = MessageType.Text,
Guid? tenantId = null)
{
return new ChatMessage
{
results.Add(result);
FormUserId = formUserId,
FormUserName = "system",
ToUserId = toUserId,
Content = content,
SendTime = clock.Now,
IsAnonymous = false,
MessageType = type,
TenantId = tenantId,
Source = MessageSourceTye.System,
}
.SetProperty("L", false);
}
return results;
/// <summary>
/// 本地化系统消息
/// 用户消息与群组消息不能使用多语言
/// </summary>
/// <param name="formUserId"></param>
/// <param name="toUserId"></param>
/// <param name="content"></param>
/// <param name="clock"></param>
/// <param name="type"></param>
/// <param name="tenantId"></param>
/// <returns></returns>
public static ChatMessage SystemLocalized(
Guid formUserId,
Guid toUserId,
LocalizableStringInfo content,
IClock clock,
MessageType type = MessageType.Text,
Guid? tenantId = null)
{
return new ChatMessage
{
FormUserId = formUserId,
FormUserName = "system",
ToUserId = toUserId,
Content = "",
SendTime = clock.Now,
IsAnonymous = false,
MessageType = type,
TenantId = tenantId,
Source = MessageSourceTye.System,
}
.SetProperty("L", true)
.SetProperty(nameof(ChatMessage.Content).ToPascalCase(), content);
}
protected virtual IEnumerable<ValidationResult> ValidateReceiver(ValidationContext validationContext)
public static ChatMessage System(
Guid formUserId,
string groupId,
string content,
IClock clock,
MessageType type = MessageType.Text,
Guid? tenantId = null)
{
if (GroupId.IsNullOrWhiteSpace() && !ToUserId.HasValue)
return new ChatMessage
{
yield return new ValidationResult("");
FormUserId = formUserId,
FormUserName = "system",
GroupId = groupId,
Content = content,
SendTime = clock.Now,
IsAnonymous = false,
MessageType = type,
TenantId = tenantId,
Source = MessageSourceTye.System,
}
.SetProperty("L", false);
}
/// <summary>
/// 本地化系统消息
/// 用户消息与群组消息不能使用多语言
/// </summary>
/// <param name="formUserId"></param>
/// <param name="groupId"></param>
/// <param name="content"></param>
/// <param name="clock"></param>
/// <param name="type"></param>
/// <param name="tenantId"></param>
/// <returns></returns>
public static ChatMessage SystemLocalized(
Guid formUserId,
string groupId,
LocalizableStringInfo content,
IClock clock,
MessageType type = MessageType.Text,
Guid? tenantId = null)
{
return new ChatMessage
{
FormUserId = formUserId,
FormUserName = "system",
GroupId = groupId,
Content = "",
SendTime = clock.Now,
IsAnonymous = false,
MessageType = type,
TenantId = tenantId,
Source = MessageSourceTye.System,
}
.SetProperty("L", true)
.SetProperty(nameof(ChatMessage.Content).ToPascalCase(), content);
}
public static ChatMessage Group(
Guid formUserId,
string formUserName,
string groupId,
string content,
IClock clock,
bool isAnonymous = false,
MessageType type = MessageType.Text,
MessageSourceTye souce = MessageSourceTye.User,
Guid? tenantId = null)
{
return new ChatMessage
{
FormUserId = formUserId,
FormUserName = formUserName,
GroupId = groupId,
Content = content,
SendTime = clock.Now,
IsAnonymous = isAnonymous,
MessageType = type,
TenantId = tenantId,
Source = souce,
};
}
}
}

64
aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Messages/LastChatMessage.cs

@ -1,9 +1,69 @@
namespace LINGYUN.Abp.IM.Messages
using System;
using Volo.Abp.Auditing;
using Volo.Abp.Data;
namespace LINGYUN.Abp.IM.Messages
{
/// <summary>
/// 上一次通讯消息
/// </summary>
public class LastChatMessage : ChatMessage
public class LastChatMessage : IHasExtraProperties
{
public string AvatarUrl { get; set; }
public string Object { get; set; }
/// <summary>
/// 租户
/// </summary>
public Guid? TenantId { get; set; }
/// <summary>
/// 群组标识
/// </summary>
public string GroupId { get; set; }
/// <summary>
/// 消息标识
/// </summary>
/// <remarks>
/// 调用者无需关注此字段,将由服务自动生成
/// </remarks>
public string MessageId { get; set; }
/// <summary>
/// 发送者标识
/// </summary>
public Guid FormUserId { get; set; }
/// <summary>
/// 发送者名称
/// </summary>
public string FormUserName { get; set; }
/// <summary>
/// 接收用户标识
/// </summary>
/// <remarks>
/// 设计为可空是为了兼容群聊消息
/// /remarks>
public string ToUserId { get; set; }
/// <summary>
/// 消息内容
/// </summary>
[DisableAuditing]
public string Content { get; set; }
/// <summary>
/// 发送时间
/// </summary>
public DateTime SendTime { get; set; }
/// <summary>
/// 是否匿名发送(存储在扩展字段)
/// </summary>
public bool IsAnonymous => this.GetProperty(nameof(IsAnonymous), false);
/// <summary>
/// 消息类型
/// </summary>
public MessageType MessageType { get; set; }
public MessageSourceTye Source { get; set; }
public ExtraPropertyDictionary ExtraProperties { get; set; }
public LastChatMessage()
{
ExtraProperties = new ExtraPropertyDictionary();
}
}
}

8
aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN/Abp/IM/Messages/MessageSourceTye.cs

@ -0,0 +1,8 @@
namespace LINGYUN.Abp.IM.Messages
{
public enum MessageSourceTye
{
User = 0,
System = 10,
}
}

2
aspnet-core/modules/common/LINGYUN.Abp.Notifications.SignalR/LINGYUN/Abp/Notifications/SignalR/AbpNotificationsSignalRModule.cs

@ -19,7 +19,7 @@ namespace LINGYUN.Abp.Notifications.SignalR
options.PublishProviders.Add<SignalRNotificationPublishProvider>();
options.NotificationDataMappings
.MappingDefault(SignalRNotificationPublishProvider.ProviderName,
data => data);
data => data.ToSignalRData());
});
Configure<AbpAspNetCoreSignalRJwtTokenMapPathOptions>(options =>

10
aspnet-core/modules/common/LINGYUN.Abp.Notifications.SignalR/LINGYUN/Abp/Notifications/SignalR/NotificationDataExtensions.cs

@ -0,0 +1,10 @@
namespace LINGYUN.Abp.Notifications.SignalR
{
internal static class NotificationDataExtensions
{
public static NotificationData ToSignalRData(this NotificationData data)
{
return data;
}
}
}

55
aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NotificationData.cs

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using LINGYUN.Abp.RealTime.Localization;
using System;
using Volo.Abp.Data;
using Volo.Abp.EventBus;
namespace LINGYUN.Abp.Notifications
@ -13,12 +14,12 @@ namespace LINGYUN.Abp.Notifications
/// </remarks>
[Serializable]
[EventName("notifications")]
public class NotificationData
public class NotificationData : IHasExtraProperties
{
/// <summary>
/// 用来标识是否需要本地化的信息
/// </summary>
public const string LocalizerKey = "localizer";
public const string LocalizerKey = "L";
public virtual string Type => GetType().FullName;
@ -26,39 +27,21 @@ namespace LINGYUN.Abp.Notifications
{
get
{
if(Properties.TryGetValue(key, out object @obj))
{
return @obj;
}
return null;
return this.GetProperty(key);
}
set { Properties[key] = value; }
}
public Dictionary<string, object> Properties
{
get { return _properties; }
set
{
if (value == null)
{
throw new ArgumentNullException(nameof(value));
}
foreach (var keyValue in value)
{
if (!_properties.ContainsKey(keyValue.Key))
{
_properties[keyValue.Key] = keyValue.Value;
}
}
this.SetProperty(key, value);
}
}
private readonly Dictionary<string, object> _properties;
public ExtraPropertyDictionary ExtraProperties { get; set; }
public NotificationData()
{
_properties = new Dictionary<string, object>();
ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties();
TrySetData(LocalizerKey, false);
}
/// <summary>
@ -146,7 +129,7 @@ namespace LINGYUN.Abp.Notifications
{
var data = ToStandardData(sourceData);
foreach(var property in sourceData.Properties)
foreach (var property in sourceData.ExtraProperties)
{
if (property.Key.StartsWith(prefix))
{
@ -159,19 +142,11 @@ namespace LINGYUN.Abp.Notifications
public object TryGetData(string key)
{
if (Properties.TryGetValue(key, out object value))
{
return value;
}
return null;
return this.GetProperty(key);
}
public void TrySetData(string key, object value)
{
if (value != null && !Properties.ContainsKey(key))
{
Properties.Add(key, value);
}
Properties[key] = value;
this.SetProperty(key, value);
}
/// <summary>
/// 需要本地化

9
aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NotificationDataConverter.cs

@ -1,4 +1,5 @@
using Newtonsoft.Json;
using LINGYUN.Abp.RealTime.Localization;
using Newtonsoft.Json;
namespace LINGYUN.Abp.Notifications
{
@ -11,18 +12,18 @@ namespace LINGYUN.Abp.Notifications
if (notificationData.NeedLocalizer())
{
// 潜在的空对象引用修复
if (notificationData.Properties.TryGetValue("title", out object title) && title != null)
if (notificationData.ExtraProperties.TryGetValue("title", out object title) && title != null)
{
var titleObj = JsonConvert.DeserializeObject<LocalizableStringInfo>(title.ToString());
notificationData.TrySetData("title", titleObj);
}
if (notificationData.Properties.TryGetValue("message", out object message) && message != null)
if (notificationData.ExtraProperties.TryGetValue("message", out object message) && message != null)
{
var messageObj = JsonConvert.DeserializeObject<LocalizableStringInfo>(message.ToString());
notificationData.TrySetData("message", messageObj);
}
if (notificationData.Properties.TryGetValue("description", out object description) && description != null)
if (notificationData.ExtraProperties.TryGetValue("description", out object description) && description != null)
{
notificationData.TrySetData("description", JsonConvert.DeserializeObject<LocalizableStringInfo>(description.ToString()));
}

2
aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/LocalizableStringInfo.cs → aspnet-core/modules/common/LINGYUN.Abp.RealTime/LINGYUN/Abp/RealTime/Localization/LocalizableStringInfo.cs

@ -1,6 +1,6 @@
using System.Collections.Generic;
namespace LINGYUN.Abp.Notifications
namespace LINGYUN.Abp.RealTime.Localization
{
/// <summary>
/// The notification that needs to be localized

5
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Chat/MyFriendAppService.cs

@ -35,7 +35,10 @@ namespace LINGYUN.Abp.MessageService.Chat
{
var friendCard = await UserChatCardRepository.GetMemberAsync(input.FriendId);
await FriendStore.AddMemberAsync(CurrentTenant.Id, CurrentUser.GetId(), input.FriendId, friendCard?.NickName ?? friendCard?.UserName ?? input.FriendId.ToString());
await FriendStore.AddMemberAsync(
CurrentTenant.Id,
CurrentUser.GetId(),
input.FriendId, friendCard?.NickName ?? friendCard?.UserName ?? input.FriendId.ToString());
}
public virtual async Task AddRequestAsync(MyFriendAddRequestDto input)

2
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/FriendStore.cs

@ -58,6 +58,7 @@ namespace LINGYUN.Abp.MessageService.Chat
Guid userId,
Guid friendId,
string remarkName = "",
bool isStatic = false,
CancellationToken cancellationToken = default)
{
using (_currentTenant.Change(tenantId))
@ -66,6 +67,7 @@ namespace LINGYUN.Abp.MessageService.Chat
{
var userFriend = new UserChatFriend(userId, friendId, remarkName);
userFriend.SetStatus(UserFriendStatus.Added);
userFriend.IsStatic = isStatic;
await _userChatFriendRepository.InsertAsync(userFriend);
}

19
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/Message.cs

@ -29,24 +29,37 @@ namespace LINGYUN.Abp.MessageService.Chat
/// </summary>
public virtual MessageType Type { get; protected set; }
/// <summary>
/// 消息来源
/// </summary>
public virtual MessageSourceTye Source { get; protected set; }
/// <summary>
/// 发送状态
/// </summary>
public virtual MessageState SendState { get; protected set; }
public virtual MessageState State { get; protected set; }
protected Message() { }
public Message(long id, Guid sendUserId, string sendUserName, string content, MessageType type = MessageType.Text)
protected Message(
long id,
Guid sendUserId,
string sendUserName,
string content,
MessageType type = MessageType.Text,
MessageSourceTye source = MessageSourceTye.User,
Guid? tenantId = null)
{
MessageId = id;
CreatorId = sendUserId;
SendUserName = sendUserName;
Content = content;
Type = type;
Source = source;
CreationTime = DateTime.Now;
TenantId = tenantId;
ChangeSendState();
}
public void ChangeSendState(MessageState state = MessageState.Send)
{
SendState = state;
State = state;
}
}
}

8
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/MessageProcessor.cs

@ -30,8 +30,8 @@ namespace LINGYUN.Abp.MessageService.Chat
{
if (!message.GroupId.IsNullOrWhiteSpace())
{
long groupId = long.Parse(message.GroupId);
var groupMessage = await _repository.GetGroupMessageAsync(groupId);
long messageId = long.Parse(message.MessageId);
var groupMessage = await _repository.GetGroupMessageAsync(messageId);
groupMessage.ChangeSendState(MessageState.Read);
await _repository.UpdateGroupMessageAsync(groupMessage);
@ -56,8 +56,8 @@ namespace LINGYUN.Abp.MessageService.Chat
if (!message.GroupId.IsNullOrWhiteSpace())
{
long groupId = long.Parse(message.GroupId);
var groupMessage = await _repository.GetGroupMessageAsync(groupId);
long messageId = long.Parse(message.MessageId);
var groupMessage = await _repository.GetGroupMessageAsync(messageId);
if (hasExpiredMessage(groupMessage))
{
throw new BusinessException(MessageServiceErrorCodes.ExpiredMessageCannotBeReCall)

21
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/MessageStore.cs

@ -64,7 +64,7 @@ namespace LINGYUN.Abp.MessageService.Chat
{
await StoreUserMessageAsync(chatMessage, cancellationToken);
}
await unitOfWork.SaveChangesAsync(cancellationToken);
await unitOfWork.CompleteAsync(cancellationToken);
}
}
}
@ -138,6 +138,11 @@ namespace LINGYUN.Abp.MessageService.Chat
{
using (_currentTenant.Change(tenantId))
{
//var messages = await _messageRepository
// .GetLastMessagesAsync(userId, state, sorting, maxResultCount, cancellationToken);
//return _objectMapper.Map<List<LastMessage>, List<LastChatMessage>>(messages);
return await _messageRepository
.GetLastMessagesAsync(userId, state, sorting, maxResultCount, cancellationToken);
}
@ -221,11 +226,12 @@ namespace LINGYUN.Abp.MessageService.Chat
long.Parse(chatMessage.MessageId),
chatMessage.FormUserId,
chatMessage.FormUserName,
chatMessage.ToUserId.Value,
chatMessage.Content,
chatMessage.MessageType);
chatMessage.MessageType,
chatMessage.Source);
message.SendToUser(chatMessage.ToUserId.Value);
message.SetProperty(nameof(ChatMessage.IsAnonymous), chatMessage.IsAnonymous);
message.ExtraProperties.AddIfNotContains(chatMessage.ExtraProperties);
await _messageRepository.InsertUserMessageAsync(message, cancellationToken);
}
@ -258,11 +264,12 @@ namespace LINGYUN.Abp.MessageService.Chat
long.Parse(chatMessage.MessageId),
chatMessage.FormUserId,
chatMessage.FormUserName,
groupId,
chatMessage.Content,
chatMessage.MessageType);
chatMessage.MessageType,
chatMessage.Source);
message.SendToGroup(groupId);
message.SetProperty(nameof(ChatMessage.IsAnonymous), chatMessage.IsAnonymous);
message.ExtraProperties.AddIfNotContains(chatMessage.ExtraProperties);
await _messageRepository.InsertGroupMessageAsync(message, cancellationToken);
}

4
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/UserChatFriend.cs

@ -20,6 +20,10 @@ namespace LINGYUN.Abp.MessageService.Chat
/// </summary>
public virtual Guid FrientId { get; protected set; }
/// <summary>
/// 系统预置
/// </summary>
public virtual bool IsStatic { get; set; }
/// <summary>
/// 已添加黑名单
/// </summary>
public virtual bool Black { get; set; }

17
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/UserMessage.cs

@ -11,13 +11,16 @@ namespace LINGYUN.Abp.MessageService.Chat
public virtual Guid ReceiveUserId { get; set; }
protected UserMessage() { }
public UserMessage(long id, Guid sendUserId, string sendUserName, string content, MessageType type = MessageType.Text)
: base(id, sendUserId, sendUserName, content, type)
{
}
public void SendToUser(Guid receiveUserId)
public UserMessage(
long id,
Guid sendUserId,
string sendUserName,
Guid receiveUserId,
string content,
MessageType type = MessageType.Text,
MessageSourceTye source = MessageSourceTye.User,
Guid? tenantId = null)
: base(id, sendUserId, sendUserName, content, type, source, tenantId)
{
ReceiveUserId = receiveUserId;
}

47
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Chat/UserOnlineChanger.cs

@ -0,0 +1,47 @@
using LINGYUN.Abp.IM;
using System;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Timing;
using Volo.Abp.Uow;
namespace LINGYUN.Abp.MessageService.Chat
{
public class UserOnlineChanger : IUserOnlineChanger, ITransientDependency
{
private readonly IClock _clock;
private readonly ICurrentTenant _currentTenant;
private readonly IUnitOfWorkManager _unitOfWorkManager;
private readonly IUserChatCardRepository _userChatCardRepository;
public UserOnlineChanger(
IClock clock,
ICurrentTenant currentTenant,
IUnitOfWorkManager unitOfWorkManager,
IUserChatCardRepository userChatCardRepository)
{
_clock = clock;
_currentTenant = currentTenant;
_unitOfWorkManager = unitOfWorkManager;
_userChatCardRepository = userChatCardRepository;
}
public virtual async Task ChangeAsync(
Guid? tenantId,
Guid userId,
UserOnlineState state,
CancellationToken cancellationToken = default)
{
using var unitOfWork = _unitOfWorkManager.Begin();
using (_currentTenant.Change(tenantId))
{
var userChatCard = await _userChatCardRepository.FindByUserIdAsync(userId);
userChatCard?.ChangeState(_clock, state);
await unitOfWork.CompleteAsync();
}
}
}
}

1
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/EventBus/Local/UserChatFriendEventHandler.cs

@ -3,6 +3,7 @@ using LINGYUN.Abp.MessageService.Chat;
using LINGYUN.Abp.MessageService.Localization;
using LINGYUN.Abp.MessageService.Notifications;
using LINGYUN.Abp.Notifications;
using LINGYUN.Abp.RealTime.Localization;
using Microsoft.Extensions.Localization;
using System;
using System.Collections.Generic;

16
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/GroupMessage.cs

@ -12,12 +12,16 @@ namespace LINGYUN.Abp.MessageService.Groups
public virtual long GroupId { get; protected set; }
protected GroupMessage() { }
public GroupMessage(long id, Guid sendUserId, string sendUserName, string content, MessageType type = MessageType.Text)
: base(id, sendUserId, sendUserName, content, type)
{
}
public void SendToGroup(long groupId)
public GroupMessage(
long id,
Guid sendUserId,
string sendUserName,
long groupId,
string content,
MessageType type = MessageType.Text,
MessageSourceTye source = MessageSourceTye.User,
Guid? tenantId = null)
: base(id, sendUserId, sendUserName, content, type, source, tenantId)
{
GroupId = groupId;
}

4
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Groups/UserGroupStore.cs

@ -55,7 +55,7 @@ namespace LINGYUN.Abp.MessageService.Groups
await _userChatGroupRepository.InsertAsync(userGroup, cancellationToken: cancellationToken);
await unitOfWork.SaveChangesAsync(cancellationToken);
await unitOfWork.CompleteAsync(cancellationToken);
}
}
}
@ -109,7 +109,7 @@ namespace LINGYUN.Abp.MessageService.Groups
{
await _userChatGroupRepository.RemoveMemberFormGroupAsync(groupId, userId, cancellationToken);
await unitOfWork.SaveChangesAsync(cancellationToken);
await unitOfWork.CompleteAsync(cancellationToken);
}
}
}

53
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/MessageServiceDomainAutoMapperProfile.cs

@ -6,8 +6,10 @@ using LINGYUN.Abp.MessageService.Groups;
using LINGYUN.Abp.MessageService.Notifications;
using LINGYUN.Abp.MessageService.Subscriptions;
using LINGYUN.Abp.Notifications;
using System;
using Volo.Abp.AutoMapper;
using Volo.Abp.Data;
using Volo.Abp.ObjectExtending;
namespace LINGYUN.Abp.MessageService.Mapper
{
@ -15,32 +17,26 @@ namespace LINGYUN.Abp.MessageService.Mapper
{
public MessageServiceDomainAutoMapperProfile()
{
//CreateMap<Notification, NotificationInfo>()
// .ForMember(dto => dto.Id, map => map.MapFrom(src => src.NotificationId))
// .ForMember(dto => dto.Name, map => map.MapFrom(src => src.NotificationName))
// .ForMember(dto => dto.Lifetime, map => map.Ignore())
// .ForMember(dto => dto.Type, map => map.MapFrom(src => src.Type))
// .ForMember(dto => dto.Severity, map => map.MapFrom(src => src.Severity))
// .ForMember(dto => dto.Data, map => map.MapFrom((src, nfi) =>
// {
// var dataType = Type.GetType(src.NotificationTypeName);
// var data = JsonConvert.DeserializeObject(src.NotificationData, dataType);
// if(data != null && data is NotificationData notificationData)
// {
// if (notificationData.NeedLocalizer())
// {
// var title = JsonConvert.DeserializeObject<LocalizableStringInfo>(notificationData.TryGetData("title").ToString());
// var message = JsonConvert.DeserializeObject<LocalizableStringInfo>(notificationData.TryGetData("message").ToString());
// notificationData.TrySetData("title", title);
// notificationData.TrySetData("message", message);
// }
// return notificationData;
// }
// return new NotificationData();
// }));
CreateMap<Notification, NotificationInfo>()
.ConvertUsing<NotificationTypeConverter>();
.ForMember(dto => dto.Id, map => map.MapFrom(src => src.NotificationId))
.ForMember(dto => dto.Name, map => map.MapFrom(src => src.NotificationName))
.ForMember(dto => dto.Lifetime, map => map.Ignore())
.ForMember(dto => dto.Type, map => map.MapFrom(src => src.Type))
.ForMember(dto => dto.Severity, map => map.MapFrom(src => src.Severity))
.ForMember(dto => dto.Data, map => map.MapFrom((src, nfi) =>
{
var dataType = Type.GetType(src.NotificationTypeName);
var data = Activator.CreateInstance(dataType);
if (data is NotificationData notificationData)
{
notificationData.ExtraProperties = src.ExtraProperties;
return notificationData;
}
return new NotificationData();
}));
//CreateMap<Notification, NotificationInfo>()
// .ConvertUsing<NotificationTypeConverter>();
CreateMap<UserSubscribe, NotificationSubscriptionInfo>();
@ -53,10 +49,6 @@ namespace LINGYUN.Abp.MessageService.Mapper
.ForMember(dto => dto.ToUserId, map => map.MapFrom(src => src.ReceiveUserId))
.Ignore(dto => dto.GroupId);
CreateMessageMap<UserMessage, LastChatMessage>()
.ForMember(dto => dto.ToUserId, map => map.MapFrom(src => src.ReceiveUserId))
.Ignore(dto => dto.GroupId);
CreateMap<ChatGroup, Group>()
.ForMember(g => g.Id, map => map.MapFrom(src => src.GroupId.ToString()))
.ForMember(g => g.MaxUserLength, map => map.MapFrom(src => src.MaxUserCount))
@ -74,8 +66,9 @@ namespace LINGYUN.Abp.MessageService.Mapper
.ForMember(dto => dto.FormUserName, map => map.MapFrom(src => src.SendUserName))
.ForMember(dto => dto.SendTime, map => map.MapFrom(src => src.CreationTime))
.ForMember(dto => dto.MessageType, map => map.MapFrom(src => src.Type))
.ForMember(dto => dto.Source, map => map.MapFrom(src => src.Source))
.ForMember(dto => dto.IsAnonymous, map => map.MapFrom(src => src.GetProperty(nameof(ChatMessage.IsAnonymous), false)))
.MapExtraProperties();
.MapExtraProperties(MappingPropertyDefinitionChecks.None);
}
}
}

7
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/NotificationTypeConverter.cs

@ -1,7 +1,6 @@
using AutoMapper;
using LINGYUN.Abp.MessageService.Notifications;
using LINGYUN.Abp.Notifications;
using Newtonsoft.Json;
using System;
using Volo.Abp;
using Volo.Abp.DependencyInjection;
@ -24,16 +23,16 @@ namespace LINGYUN.Abp.MessageService.Mapper
var dataType = Type.GetType(source.NotificationTypeName);
Check.NotNull(dataType, source.NotificationTypeName);
var data = JsonConvert.DeserializeObject(source.NotificationData, dataType);
var data = Activator.CreateInstance(dataType);
if (data != null && data is NotificationData notificationData)
{
notificationData.ExtraProperties = source.ExtraProperties;
destination.Data = NotificationDataConverter.Convert(notificationData);
}
else
{
destination.Data = new NotificationData();
destination.Data.TrySetData("data", source.NotificationData);
destination.Data.ExtraProperties = source.ExtraProperties;
}
return destination;
}

33
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/Notification.cs

@ -1,40 +1,59 @@
using LINGYUN.Abp.Notifications;
using System;
using Volo.Abp.Auditing;
using Volo.Abp.Data;
using Volo.Abp.Domain.Entities;
using Volo.Abp.MultiTenancy;
namespace LINGYUN.Abp.MessageService.Notifications
{
public class Notification : Entity<long>, IMultiTenant, IHasCreationTime
public class Notification : Entity<long>, IMultiTenant, IHasCreationTime, IHasExtraProperties
{
public virtual Guid? TenantId { get; protected set; }
public virtual NotificationSeverity Severity { get; protected set; }
public virtual NotificationType Type { get; set; }
public virtual long NotificationId { get; protected set; }
public virtual string NotificationName { get; protected set; }
public virtual string NotificationData { get; protected set; }
public virtual string NotificationTypeName { get; protected set; }
public virtual DateTime? ExpirationTime { get; set; }
public virtual DateTime CreationTime { get; set; }
protected Notification(){}
public virtual ExtraPropertyDictionary ExtraProperties { get; protected set; }
public Notification(long id)
protected Notification()
{
ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties();
}
public Notification(long id) : this()
{
Id = id;
}
public Notification(long id, string name, string dataType, string data,
public Notification(
long id,
string name,
string dataType,
NotificationData data,
NotificationSeverity severity = NotificationSeverity.Info,
Guid? tenantId = null)
Guid? tenantId = null) : this()
{
NotificationId = id;
Severity = severity;
NotificationName = name;
NotificationData = data;
NotificationTypeName = dataType;
Type = NotificationType.Application;
TenantId = tenantId;
SetData(data);
}
public void SetData(NotificationData data)
{
foreach (var property in data.ExtraProperties)
{
this.SetProperty(property.Key, property.Value);
}
}
}
}

40
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationStore.cs

@ -7,7 +7,6 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Json;
using Volo.Abp.MultiTenancy;
using Volo.Abp.ObjectMapping;
using Volo.Abp.Timing;
@ -25,8 +24,6 @@ namespace LINGYUN.Abp.MessageService.Notifications
private readonly ICurrentTenant _currentTenant;
private readonly IJsonSerializer _jsonSerializer;
private readonly IUnitOfWorkManager _unitOfWorkManager;
private readonly INotificationRepository _notificationRepository;
@ -39,7 +36,6 @@ namespace LINGYUN.Abp.MessageService.Notifications
IClock clock,
IObjectMapper objectMapper,
ICurrentTenant currentTenant,
IJsonSerializer jsonSerializer,
IUnitOfWorkManager unitOfWorkManager,
INotificationRepository notificationRepository,
IUserSubscribeRepository userSubscribeRepository,
@ -49,7 +45,6 @@ namespace LINGYUN.Abp.MessageService.Notifications
_clock = clock;
_objectMapper = objectMapper;
_currentTenant = currentTenant;
_jsonSerializer = jsonSerializer;
_unitOfWorkManager = unitOfWorkManager;
_notificationRepository = notificationRepository;
_userSubscribeRepository = userSubscribeRepository;
@ -72,7 +67,7 @@ namespace LINGYUN.Abp.MessageService.Notifications
notification.ChangeReadState(readState);
await _userNotificationRepository.UpdateAsync(notification);
await unitOfWork.SaveChangesAsync();
await unitOfWork.CompleteAsync();
}
}
}
@ -87,7 +82,7 @@ namespace LINGYUN.Abp.MessageService.Notifications
var notify = await _notificationRepository.GetByIdAsync(notification.GetId(), cancellationToken);
await _notificationRepository.DeleteAsync(notify.Id, cancellationToken: cancellationToken);
await unitOfWork.SaveChangesAsync(cancellationToken);
await unitOfWork.CompleteAsync(cancellationToken);
}
}
@ -99,7 +94,7 @@ namespace LINGYUN.Abp.MessageService.Notifications
{
await _notificationRepository.DeleteExpritionAsync(batchCount, cancellationToken);
await unitOfWork.SaveChangesAsync(cancellationToken);
await unitOfWork.CompleteAsync(cancellationToken);
}
}
@ -117,7 +112,7 @@ namespace LINGYUN.Abp.MessageService.Notifications
await _userNotificationRepository
.DeleteAsync(notify.Id, cancellationToken: cancellationToken);
await unitOfWork.SaveChangesAsync(cancellationToken);
await unitOfWork.CompleteAsync(cancellationToken);
}
}
@ -132,7 +127,7 @@ namespace LINGYUN.Abp.MessageService.Notifications
await _userSubscribeRepository
.DeleteUserSubscriptionAsync(notificationName, cancellationToken);
await unitOfWork.SaveChangesAsync(cancellationToken);
await unitOfWork.CompleteAsync(cancellationToken);
}
}
@ -150,7 +145,7 @@ namespace LINGYUN.Abp.MessageService.Notifications
await _userSubscribeRepository
.DeleteAsync(userSubscribe.Id, cancellationToken: cancellationToken);
await unitOfWork.SaveChangesAsync(cancellationToken);
await unitOfWork.CompleteAsync(cancellationToken);
}
}
@ -166,7 +161,7 @@ namespace LINGYUN.Abp.MessageService.Notifications
await _userSubscribeRepository
.DeleteUserSubscriptionAsync(notificationName, identifiers.Select(ids => ids.UserId), cancellationToken);
await unitOfWork.SaveChangesAsync(cancellationToken);
await unitOfWork.CompleteAsync(cancellationToken);
}
}
@ -320,8 +315,9 @@ namespace LINGYUN.Abp.MessageService.Notifications
notification.GetId(),
notification.Name,
notification.Data.GetType().AssemblyQualifiedName,
_jsonSerializer.Serialize(notification.Data),
notification.Severity, notification.TenantId)
notification.Data,
notification.Severity,
notification.TenantId)
{
CreationTime = _clock.Now,
Type = notification.Type,
@ -331,9 +327,9 @@ namespace LINGYUN.Abp.MessageService.Notifications
await _notificationRepository.InsertAsync(notify, cancellationToken: cancellationToken);
notification.Id = notify.NotificationId.ToString();
notification.SetId(notify.NotificationId);
await unitOfWork.SaveChangesAsync(cancellationToken);
await unitOfWork.CompleteAsync(cancellationToken);
}
}
@ -349,7 +345,7 @@ namespace LINGYUN.Abp.MessageService.Notifications
await _userNotificationRepository
.InsertAsync(userNotification, cancellationToken: cancellationToken);
await unitOfWork.SaveChangesAsync(cancellationToken);
await unitOfWork.CompleteAsync(cancellationToken);
}
}
@ -371,7 +367,7 @@ namespace LINGYUN.Abp.MessageService.Notifications
await _userSubscribeRepository
.InsertAsync(userSubscription, cancellationToken: cancellationToken);
await unitOfWork.SaveChangesAsync(cancellationToken);
await unitOfWork.CompleteAsync(cancellationToken);
}
}
@ -394,7 +390,7 @@ namespace LINGYUN.Abp.MessageService.Notifications
await _userSubscribeRepository
.InsertUserSubscriptionAsync(userSubscribes, cancellationToken);
await unitOfWork.SaveChangesAsync(cancellationToken);
await unitOfWork.CompleteAsync(cancellationToken);
}
}
@ -405,8 +401,8 @@ namespace LINGYUN.Abp.MessageService.Notifications
CancellationToken cancellationToken = default)
{
using (_currentTenant.Change(tenantId))
return await _userSubscribeRepository
.UserSubscribeExistsAysnc(notificationName, userId, cancellationToken);
return await _userSubscribeRepository
.UserSubscribeExistsAysnc(notificationName, userId, cancellationToken);
}
public virtual async Task InsertUserNotificationsAsync(
@ -431,7 +427,7 @@ namespace LINGYUN.Abp.MessageService.Notifications
await _userNotificationRepository
.InsertUserNotificationsAsync(userNofitications, cancellationToken);
await unitOfWork.SaveChangesAsync(cancellationToken);
await unitOfWork.CompleteAsync(cancellationToken);
}
}
}

307
aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreMessageRepository.cs

@ -2,15 +2,22 @@
using LINGYUN.Abp.MessageService.EntityFrameworkCore;
using LINGYUN.Abp.MessageService.Groups;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data.Common;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Json.SystemTextJson.JsonConverters;
namespace LINGYUN.Abp.MessageService.Chat
{
@ -45,7 +52,8 @@ namespace LINGYUN.Abp.MessageService.Chat
var groupMessages = await (await GetDbContextAsync()).Set<GroupMessage>()
.Distinct()
.Where(x => x.GroupId.Equals(groupId))
.WhereIf(type != null, x => x.Type.Equals(type))
.Where(x => x.State == MessageState.Send || x.State == MessageState.Read)
.WhereIf(type.HasValue, x => x.Type.Equals(type))
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Content.Contains(filter) || x.SendUserName.Contains(filter))
.OrderBy(sorting ?? nameof(GroupMessage.MessageId))
.PageBy(skipCount, maxResultCount)
@ -64,7 +72,8 @@ namespace LINGYUN.Abp.MessageService.Chat
var groupMessagesCount = await (await GetDbContextAsync()).Set<GroupMessage>()
.Distinct()
.Where(x => x.GroupId.Equals(groupId))
.WhereIf(type != null, x => x.Type.Equals(type))
.Where(x => x.State == MessageState.Send || x.State == MessageState.Read)
.WhereIf(type.HasValue, x => x.Type.Equals(type))
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Content.Contains(filter) || x.SendUserName.Contains(filter))
.LongCountAsync(GetCancellationToken(cancellationToken));
return groupMessagesCount;
@ -153,37 +162,271 @@ namespace LINGYUN.Abp.MessageService.Chat
int maxResultCount = 10,
CancellationToken cancellationToken = default)
{
sorting ??= $"{nameof(LastChatMessage.SendTime)} DESC";
var dbContext = await GetDbContextAsync();
var groupMsgQuery = dbContext.Set<UserMessage>()
.Where(msg => msg.ReceiveUserId == userId)
.WhereIf(state.HasValue, x => x.SendState == state)
.GroupBy(msg => new { msg.CreatorId, msg.ReceiveUserId })
.Select(msg => new
#region SQL 原型
var sqlBuilder = new StringBuilder(1280);
sqlBuilder.AppendLine("SELECT");
sqlBuilder.AppendLine(" msg.* ");
sqlBuilder.AppendLine("FROM");
sqlBuilder.AppendLine(" (");
sqlBuilder.AppendLine(" SELECT");
sqlBuilder.AppendLine(" um.Content,");
sqlBuilder.AppendLine(" um.CreationTime,");
sqlBuilder.AppendLine(" um.CreatorId,");
sqlBuilder.AppendLine(" um.SendUserName,");
sqlBuilder.AppendLine(" ac.NickName AS Object,");
sqlBuilder.AppendLine(" ac.AvatarUrl,");
sqlBuilder.AppendLine(" um.Source,");
sqlBuilder.AppendLine(" um.MessageId,");
sqlBuilder.AppendLine(" um.Type,");
sqlBuilder.AppendLine(" um.TenantId,");
sqlBuilder.AppendLine(" um.ReceiveUserId,");
sqlBuilder.AppendLine(" '' AS GroupId,");
sqlBuilder.AppendLine(" um.ExtraProperties");
sqlBuilder.AppendLine(" FROM");
sqlBuilder.AppendLine(" (");
sqlBuilder.AppendLine(" SELECT");
sqlBuilder.AppendLine(" um.* ");
sqlBuilder.AppendLine(" FROM");
sqlBuilder.AppendLine(" appusermessages um");
sqlBuilder.AppendLine(" INNER JOIN ( SELECT max( um.MessageId ) AS MessageId FROM appusermessages um");
sqlBuilder.AppendLine(" WHERE");
sqlBuilder.AppendLine(" um.ReceiveUserId = @ReceiveUserId");
if (state.HasValue)
{
sqlBuilder.AppendLine(" AND um.State = @State");
}
if (CurrentTenant.IsAvailable)
{
sqlBuilder.AppendLine(" AND um.TenantId = @TenantId");
}
sqlBuilder.AppendLine(" GROUP BY um.ReceiveUserId ) gum ON um.MessageId = gum.MessageId");
sqlBuilder.AppendLine(" ) um");
sqlBuilder.AppendLine(" LEFT JOIN appuserchatcards ac ON ac.UserId = um.CreatorId ");
sqlBuilder.AppendLine(" UNION ALL");
sqlBuilder.AppendLine(" SELECT");
sqlBuilder.AppendLine(" gm.Content,");
sqlBuilder.AppendLine(" gm.CreationTime,");
sqlBuilder.AppendLine(" gm.CreatorId,");
sqlBuilder.AppendLine(" gm.SendUserName,");
sqlBuilder.AppendLine(" ag.Name AS Object,");
sqlBuilder.AppendLine(" ag.AvatarUrl,");
sqlBuilder.AppendLine(" gm.Source,");
sqlBuilder.AppendLine(" gm.MessageId,");
sqlBuilder.AppendLine(" gm.Type,");
sqlBuilder.AppendLine(" gm.TenantId,");
sqlBuilder.AppendLine(" '' AS ReceiveUserId,");
sqlBuilder.AppendLine(" gm.GroupId,");
sqlBuilder.AppendLine(" gm.ExtraProperties");
sqlBuilder.AppendLine(" FROM");
sqlBuilder.AppendLine(" appgroupmessages gm");
sqlBuilder.AppendLine(" INNER JOIN (");
sqlBuilder.AppendLine(" SELECT");
sqlBuilder.AppendLine(" max( gm.MessageId ) AS MessageId ");
sqlBuilder.AppendLine(" FROM");
sqlBuilder.AppendLine(" appuserchatcards ac");
sqlBuilder.AppendLine(" LEFT JOIN appuserchatgroups acg ON acg.UserId = ac.UserId");
sqlBuilder.AppendLine(" LEFT JOIN appgroupmessages gm ON gm.GroupId = acg.GroupId ");
sqlBuilder.AppendLine(" WHERE");
sqlBuilder.AppendLine(" ac.UserId = @ReceiveUserId ");
if (state.HasValue)
{
sqlBuilder.AppendLine(" AND gm.State = @State");
}
if (CurrentTenant.IsAvailable)
{
sqlBuilder.AppendLine(" AND gm.TenantId = @TenantId");
}
sqlBuilder.AppendLine(" GROUP BY");
sqlBuilder.AppendLine(" gm.GroupId");
sqlBuilder.AppendLine(" ) ggm ON ggm.MessageId = gm.MessageId ");
sqlBuilder.AppendLine(" INNER JOIN appchatgroups ag on ag.GroupId = gm.GroupId");
sqlBuilder.AppendLine(" ) AS msg");
sqlBuilder.AppendLine("ORDER BY ");
sqlBuilder.AppendLine(" @Sorting");
sqlBuilder.AppendLine(" LIMIT @MaxResultCount");
using var dbContection = dbContext.Database.GetDbConnection();
await dbContection.OpenAsync();
using var command = dbContection.CreateCommand();
command.Transaction = dbContext.Database.CurrentTransaction?.GetDbTransaction();
command.CommandText = sqlBuilder.ToString();
var receivedUser = command.CreateParameter();
receivedUser.DbType = System.Data.DbType.Guid;
receivedUser.ParameterName = "@ReceiveUserId";
receivedUser.Value = userId;
command.Parameters.Add(receivedUser);
var sorttingParam = command.CreateParameter();
sorttingParam.DbType = System.Data.DbType.String;
sorttingParam.ParameterName = "@Sorting";
sorttingParam.Value = sorting;
command.Parameters.Add(sorttingParam);
var limitParam = command.CreateParameter();
limitParam.DbType = System.Data.DbType.Int32;
limitParam.ParameterName = "@MaxResultCount";
limitParam.Value = maxResultCount;
command.Parameters.Add(limitParam);
if (state.HasValue)
{
var stateParam = command.CreateParameter();
stateParam.DbType = System.Data.DbType.Int32;
stateParam.ParameterName = "@State";
stateParam.Value = (int)state.Value;
command.Parameters.Add(stateParam);
}
if (CurrentTenant.IsAvailable)
{
var tenantParam = command.CreateParameter();
tenantParam.DbType = System.Data.DbType.Guid;
tenantParam.ParameterName = "@TenantId";
tenantParam.Value = CurrentTenant.Id.Value;
command.Parameters.Add(tenantParam);
}
var messages = new List<LastChatMessage>();
using var reader = await command.ExecuteReaderAsync();
T GetValue<T>(DbDataReader reader, int index)
{
var value = reader.GetValue(index);
if (value == null || value == DBNull.Value)
{
return default;
}
var valueType = typeof(T);
var converter = TypeDescriptor.GetConverter(valueType);
if (converter.CanConvertFrom(value.GetType()))
{
return (T)converter.ConvertFrom(value);
}
return (T)Convert.ChangeType(value, typeof(T));
};
ExtraPropertyDictionary GetExtraProperties(DbDataReader reader, int index)
{
var value = reader.GetValue(index);
if (value == null || value == DBNull.Value)
{
return new ExtraPropertyDictionary();
}
var extraPropertiesAsJson = value.ToString();
if (extraPropertiesAsJson.IsNullOrEmpty() || extraPropertiesAsJson == "{}")
{
msg.Key.CreatorId,
msg.Key.ReceiveUserId,
MessageId = msg.Max(x => x.MessageId)
return new ExtraPropertyDictionary();
}
var deserializeOptions = new JsonSerializerOptions();
deserializeOptions.Converters.Add(new ObjectToInferredTypesConverter());
var dictionary = JsonSerializer.Deserialize<ExtraPropertyDictionary>(extraPropertiesAsJson, deserializeOptions) ??
new ExtraPropertyDictionary();
return dictionary;
}
while (reader.Read())
{
messages.Add(new LastChatMessage
{
Content = GetValue<string>(reader, 0),
SendTime = GetValue<DateTime>(reader, 1),
FormUserId = GetValue<Guid>(reader, 2),
FormUserName = GetValue<string>(reader, 3),
Object = GetValue<string>(reader, 4),
AvatarUrl = GetValue<string>(reader, 5),
Source = (MessageSourceTye)GetValue<int>(reader, 6),
MessageId = GetValue<string>(reader, 7),
MessageType = (MessageType)GetValue<int>(reader, 8),
TenantId = GetValue<Guid?>(reader, 9),
ToUserId = GetValue<string>(reader, 10),
GroupId = GetValue<string>(reader, 11),
ExtraProperties = GetExtraProperties(reader, 12),
});
}
return messages;
#endregion
#region 待 EF 团队解决此问题
//// 聚合用户消息
//var aggreUserMsgIdQuery = dbContext.Set<UserMessage>()
// .Where(msg => msg.ReceiveUserId == userId)
// .WhereIf(state.HasValue, x => x.SendState == state)
// .GroupBy(msg => msg.ReceiveUserId)
// .Select(msg => new
// {
// MessageId = msg.Max(x => x.MessageId)
// });
//var joinUserMsg = from um in dbContext.Set<UserMessage>()
// join aum in aggreUserMsgIdQuery
// on um.MessageId equals aum.MessageId
// join ucc in dbContext.Set<UserChatCard>()
// on um.CreatorId equals ucc.UserId
// select new LastChatMessage
// {
// Content = um.Content,
// SendTime = um.CreationTime,
// FormUserId = um.CreatorId.Value,
// FormUserName = um.SendUserName,
// Object = ucc.NickName,
// AvatarUrl = ucc.AvatarUrl,
// Source = um.Source,
// MessageId = Convert.ToString(um.MessageId),
// MessageType = um.Type,
// TenantId = um.TenantId,
// // ToUserId = Convert.ToString(um.ReceiveUserId),
// // GroupId = "",
// };
//// 聚合群组消息
//var aggreGroupMsgIdQuery = from ucc in dbContext.Set<UserChatCard>()
// join ucg in dbContext.Set<UserChatGroup>()
// on ucc.UserId equals ucg.UserId
// join gm in dbContext.Set<GroupMessage>()
// on ucg.GroupId equals gm.GroupId
// where ucc.UserId.Equals(userId)
// group gm by gm.GroupId into ggm
// select new
// {
// MessageId = ggm.Max(gm => gm.MessageId),
// };
//var joinGroupMsg = from gm in dbContext.Set<GroupMessage>()
// join agm in aggreGroupMsgIdQuery
// on gm.MessageId equals agm.MessageId
// join cg in dbContext.Set<ChatGroup>()
// on gm.GroupId equals cg.GroupId
// select new LastChatMessage
// {
// Content = gm.Content,
// SendTime = gm.CreationTime,
// FormUserId = gm.CreatorId.Value,
// FormUserName = gm.SendUserName,
// Object = cg.Name,
// AvatarUrl = cg.AvatarUrl,
// Source = gm.Source,
// MessageId = Convert.ToString(gm.MessageId),
// MessageType = gm.Type,
// TenantId = gm.TenantId,
// // ToUserId = "",
// // GroupId = Convert.ToString(gm.GroupId)
// };
//return await joinUserMsg
// .Concat(joinGroupMsg)
// .OrderBy(sorting)
// .Take(maxResultCount)
// .ToListAsync(GetCancellationToken(cancellationToken));
#endregion
var userMessageQuery = from msg in dbContext.Set<UserMessage>()
join gMsg in groupMsgQuery
on msg.MessageId equals gMsg.MessageId
select new LastChatMessage
{
Content = msg.Content,
SendTime = msg.CreationTime,
FormUserId = msg.CreatorId.Value,
FormUserName = msg.SendUserName,
MessageId = msg.MessageId.ToString(),
MessageType = msg.Type,
TenantId = msg.TenantId,
ToUserId = msg.ReceiveUserId
};
return await userMessageQuery
.OrderBy(sorting ?? nameof(LastChatMessage.SendTime))
.Take(maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<List<UserMessage>> GetUserMessagesAsync(
@ -199,7 +442,8 @@ namespace LINGYUN.Abp.MessageService.Chat
var userMessages = await (await GetDbContextAsync()).Set<UserMessage>()
.Where(x => (x.CreatorId.Equals(sendUserId) && x.ReceiveUserId.Equals(receiveUserId)) ||
x.CreatorId.Equals(receiveUserId) && x.ReceiveUserId.Equals(sendUserId))
.WhereIf(type != null, x => x.Type.Equals(type))
.WhereIf(type.HasValue, x => x.Type.Equals(type))
.Where(x => x.State == MessageState.Send || x.State == MessageState.Read)
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Content.Contains(filter) || x.SendUserName.Contains(filter))
.OrderBy(sorting ?? nameof(UserMessage.MessageId))
.PageBy(skipCount, maxResultCount)
@ -219,7 +463,8 @@ namespace LINGYUN.Abp.MessageService.Chat
var userMessagesCount = await (await GetDbContextAsync()).Set<UserMessage>()
.Where(x => (x.CreatorId.Equals(sendUserId) && x.ReceiveUserId.Equals(receiveUserId)) ||
x.CreatorId.Equals(receiveUserId) && x.ReceiveUserId.Equals(sendUserId))
.WhereIf(type != null, x => x.Type.Equals(type))
.WhereIf(type.HasValue, x => x.Type.Equals(type))
.Where(x => x.State == MessageState.Send || x.State == MessageState.Read)
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Content.Contains(filter) || x.SendUserName.Contains(filter))
.LongCountAsync(GetCancellationToken(cancellationToken));

2
aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContextModelCreatingExtensions.cs

@ -27,7 +27,7 @@ namespace LINGYUN.Abp.MessageService.EntityFrameworkCore
b.Property(p => p.NotificationName).HasMaxLength(NotificationConsts.MaxNameLength).IsRequired();
b.Property(p => p.NotificationTypeName).HasMaxLength(NotificationConsts.MaxTypeNameLength).IsRequired();
b.Property(p => p.NotificationData).HasMaxLength(NotificationConsts.MaxDataLength).IsRequired();
//b.Property(p => p.NotificationData).HasMaxLength(NotificationConsts.MaxDataLength).IsRequired();
b.ConfigureByConvention();

3
aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreUserNotificationRepository.cs

@ -106,6 +106,7 @@ namespace LINGYUN.Abp.MessageService.Notifications
int maxResultCount = 10,
CancellationToken cancellationToken = default)
{
sorting ??= $"{nameof(Notification.CreationTime)} DESC";
var dbContext = await GetDbContextAsync();
var userNotifilerQuery = dbContext.Set<UserNotification>()
.Where(x => x.UserId == userId)
@ -120,7 +121,7 @@ namespace LINGYUN.Abp.MessageService.Notifications
.WhereIf(!filter.IsNullOrWhiteSpace(), nf =>
nf.NotificationName.Contains(filter) ||
nf.NotificationTypeName.Contains(filter))
.OrderBy(sorting ??= nameof(Notification.CreationTime))
.OrderBy(sorting)
.PageBy(skipCount, maxResultCount)
.AsNoTracking()
.ToListAsync(GetCancellationToken(cancellationToken));

6
aspnet-core/modules/wechat/LINGYUN.Abp.Notifications.WeChat.MiniProgram/LINGYUN/Abp/Notifications/WeChat/MiniProgram/WeChatMiniProgramNotificationPublishProvider.cs

@ -72,13 +72,13 @@ namespace LINGYUN.Abp.Notifications.WeChat.MiniProgram
await SubscribeMessager
.SendAsync(
identifier.UserId, templateId, redirect, weAppLang,
weAppState, notification.Data.Properties, cancellationToken);
weAppState, notification.Data.ExtraProperties, cancellationToken);
}
else
{
var weChatWeAppNotificationData = new SubscribeMessage(templateId, redirect, weAppState, weAppLang);
// 写入模板数据
weChatWeAppNotificationData.WriteData(notification.Data.Properties);
weChatWeAppNotificationData.WriteData(notification.Data.ExtraProperties);
Logger.LogDebug($"Sending wechat weapp notification: {notification.Name}");
@ -94,7 +94,7 @@ namespace LINGYUN.Abp.Notifications.WeChat.MiniProgram
protected string GetOrDefault(NotificationData data, string key, string defaultValue)
{
if (data.Properties.TryGetValue(key, out object value))
if (data.ExtraProperties.TryGetValue(key, out object value))
{
// 取得了数据就删除对应键值
// data.Properties.Remove(key);

5
aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/AbpMessageServiceHttpApiHostModule.cs

@ -109,15 +109,12 @@ namespace LINGYUN.Abp.MessageService
app.UseRouting();
// 跨域
app.UseCors(DefaultCorsPolicyName);
// 加入自定义中间件
app.UseSignalRJwtToken();
// TODO: 还有没有其他方法在iframe中传递身份令牌?
app.UseHangfireAuthorication();
// 认证
app.UseAuthentication();
app.UseAbpClaimsMap();
// jwt
app.UseJwtTokenMiddleware();
// 授权
app.UseAuthorization();
// 多租户
app.UseMultiTenancy();

3
aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/EventBus/Distributed/TenantSynchronizer.cs

@ -3,6 +3,7 @@ using LINGYUN.Abp.MessageService.EntityFrameworkCore;
using LINGYUN.Abp.MessageService.Localization;
using LINGYUN.Abp.MultiTenancy;
using LINGYUN.Abp.Notifications;
using LINGYUN.Abp.RealTime.Localization;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using System;
@ -62,7 +63,7 @@ namespace LINGYUN.Abp.MessageService.EventBus.Distributed
await SendNotificationAsync(eventData);
await unitOfWork.SaveChangesAsync();
await unitOfWork.CompleteAsync();
}
}
}

2
aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/EventBus/Local/UserCreateJoinIMEventHandler.cs

@ -30,6 +30,8 @@ namespace LINGYUN.Abp.MessageService.EventBus.Distributed
public virtual async Task HandleEventAsync(EntityCreatedEventData<UserEto> eventData)
{
await SeedChatDataAsync(eventData.Entity);
await SeedUserSubscriptionNotifiersAsync(eventData.Entity);
}
protected virtual async Task SeedChatDataAsync(IUserData user)

1
aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/EventBus/Local/UserCreateSendWelcomeEventHandler.cs

@ -1,5 +1,6 @@
using LINGYUN.Abp.MessageService.Localization;
using LINGYUN.Abp.Notifications;
using LINGYUN.Abp.RealTime.Localization;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

621
aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/Migrations/20211111014501_Add-Base-Type-ExtraProp-To-Notification.Designer.cs

@ -0,0 +1,621 @@
// <auto-generated />
using System;
using LINGYUN.Abp.MessageService.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Volo.Abp.EntityFrameworkCore;
namespace LINGYUN.Abp.MessageService.Migrations
{
[DbContext(typeof(MessageServiceHostMigrationsDbContext))]
[Migration("20211111014501_Add-Base-Type-ExtraProp-To-Notification")]
partial class AddBaseTypeExtraPropToNotification
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql)
.HasAnnotation("Relational:MaxIdentifierLength", 64)
.HasAnnotation("ProductVersion", "5.0.12");
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatCard", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<int>("Age")
.HasColumnType("int");
b.Property<string>("AvatarUrl")
.HasMaxLength(512)
.HasColumnType("varchar(512)");
b.Property<DateTime?>("Birthday")
.HasColumnType("datetime(6)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("Description")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<DateTime?>("LastOnlineTime")
.HasColumnType("datetime(6)");
b.Property<string>("NickName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<int>("Sex")
.HasColumnType("int");
b.Property<string>("Sign")
.HasMaxLength(30)
.HasColumnType("varchar(30)");
b.Property<int>("State")
.HasColumnType("int");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.Property<string>("UserName")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId");
b.ToTable("AppUserChatCards");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatFriend", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<bool>("Black")
.HasColumnType("tinyint(1)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("Description")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<bool>("DontDisturb")
.HasColumnType("tinyint(1)");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<Guid>("FrientId")
.HasColumnType("char(36)");
b.Property<string>("RemarkName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<bool>("SpecialFocus")
.HasColumnType("tinyint(1)");
b.Property<byte>("Status")
.HasColumnType("tinyint unsigned");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId", "FrientId");
b.ToTable("AppUserChatFriends");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatSetting", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<bool>("AllowAddFriend")
.HasColumnType("tinyint(1)");
b.Property<bool>("AllowAnonymous")
.HasColumnType("tinyint(1)");
b.Property<bool>("AllowReceiveMessage")
.HasColumnType("tinyint(1)");
b.Property<bool>("AllowSendMessage")
.HasColumnType("tinyint(1)");
b.Property<bool>("RequireAddFriendValition")
.HasColumnType("tinyint(1)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId");
b.ToTable("AppUserChatSettings");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserMessage", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("Content")
.IsRequired()
.HasMaxLength(1048576)
.HasColumnType("longtext");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<long>("MessageId")
.HasColumnType("bigint");
b.Property<Guid>("ReceiveUserId")
.HasColumnType("char(36)");
b.Property<sbyte>("SendState")
.HasColumnType("tinyint");
b.Property<string>("SendUserName")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("varchar(64)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TenantId", "ReceiveUserId");
b.ToTable("AppUserMessages");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.ChatGroup", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<string>("Address")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<Guid>("AdminUserId")
.HasColumnType("char(36)");
b.Property<bool>("AllowAnonymous")
.HasColumnType("tinyint(1)");
b.Property<bool>("AllowSendMessage")
.HasColumnType("tinyint(1)");
b.Property<string>("AvatarUrl")
.HasMaxLength(128)
.HasColumnType("varchar(128)");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("Description")
.HasMaxLength(128)
.HasColumnType("varchar(128)");
b.Property<long>("GroupId")
.HasColumnType("bigint");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<int>("MaxUserCount")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("varchar(20)");
b.Property<string>("Notice")
.HasMaxLength(64)
.HasColumnType("varchar(64)");
b.Property<string>("Tag")
.HasMaxLength(512)
.HasColumnType("varchar(512)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.HasKey("Id");
b.HasIndex("TenantId", "Name");
b.ToTable("AppChatGroups");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupChatBlack", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<long>("GroupId")
.HasColumnType("bigint");
b.Property<Guid>("ShieldUserId")
.HasColumnType("char(36)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.HasKey("Id");
b.HasIndex("TenantId", "GroupId");
b.ToTable("AppGroupChatBlacks");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupMessage", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("Content")
.IsRequired()
.HasMaxLength(1048576)
.HasColumnType("longtext");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<long>("GroupId")
.HasColumnType("bigint");
b.Property<long>("MessageId")
.HasColumnType("bigint");
b.Property<sbyte>("SendState")
.HasColumnType("tinyint");
b.Property<string>("SendUserName")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("varchar(64)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TenantId", "GroupId");
b.ToTable("AppGroupMessages");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserChatGroup", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<long>("GroupId")
.HasColumnType("bigint");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "GroupId", "UserId");
b.ToTable("AppUserChatGroups");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserGroupCard", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<bool>("IsAdmin")
.HasColumnType("tinyint(1)");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<string>("NickName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<DateTime?>("SilenceEnd")
.HasColumnType("datetime(6)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId");
b.ToTable("AppUserGroupCards");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.Notification", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<DateTime?>("ExpirationTime")
.HasColumnType("datetime(6)");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<long>("NotificationId")
.HasColumnType("bigint");
b.Property<string>("NotificationName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<string>("NotificationTypeName")
.IsRequired()
.HasMaxLength(512)
.HasColumnType("varchar(512)");
b.Property<sbyte>("Severity")
.HasColumnType("tinyint");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TenantId", "NotificationName");
b.ToTable("AppNotifications");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.UserNotification", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<long>("NotificationId")
.HasColumnType("bigint");
b.Property<int>("ReadStatus")
.HasColumnType("int");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId", "NotificationId")
.HasDatabaseName("IX_Tenant_User_Notification_Id");
b.ToTable("AppUserNotifications");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Subscriptions.UserSubscribe", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<string>("NotificationName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.Property<string>("UserName")
.IsRequired()
.ValueGeneratedOnAdd()
.HasMaxLength(128)
.HasColumnType("varchar(128)")
.HasDefaultValue("/");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId", "NotificationName")
.IsUnique()
.HasDatabaseName("IX_Tenant_User_Notification_Name");
b.ToTable("AppUserSubscribes");
});
#pragma warning restore 612, 618
}
}
}

36
aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/Migrations/20211111014501_Add-Base-Type-ExtraProp-To-Notification.cs

@ -0,0 +1,36 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace LINGYUN.Abp.MessageService.Migrations
{
public partial class AddBaseTypeExtraPropToNotification : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "NotificationData",
table: "AppNotifications");
migrationBuilder.AddColumn<string>(
name: "ExtraProperties",
table: "AppNotifications",
type: "longtext",
nullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ExtraProperties",
table: "AppNotifications");
migrationBuilder.AddColumn<string>(
name: "NotificationData",
table: "AppNotifications",
type: "longtext",
maxLength: 1048576,
nullable: false)
.Annotation("MySql:CharSet", "utf8mb4");
}
}
}

627
aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/Migrations/20211111080938_Add-Source-Type-To-Chat-Message.Designer.cs

@ -0,0 +1,627 @@
// <auto-generated />
using System;
using LINGYUN.Abp.MessageService.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Volo.Abp.EntityFrameworkCore;
namespace LINGYUN.Abp.MessageService.Migrations
{
[DbContext(typeof(MessageServiceHostMigrationsDbContext))]
[Migration("20211111080938_Add-Source-Type-To-Chat-Message")]
partial class AddSourceTypeToChatMessage
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql)
.HasAnnotation("Relational:MaxIdentifierLength", 64)
.HasAnnotation("ProductVersion", "5.0.12");
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatCard", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<int>("Age")
.HasColumnType("int");
b.Property<string>("AvatarUrl")
.HasMaxLength(512)
.HasColumnType("varchar(512)");
b.Property<DateTime?>("Birthday")
.HasColumnType("datetime(6)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("Description")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<DateTime?>("LastOnlineTime")
.HasColumnType("datetime(6)");
b.Property<string>("NickName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<int>("Sex")
.HasColumnType("int");
b.Property<string>("Sign")
.HasMaxLength(30)
.HasColumnType("varchar(30)");
b.Property<int>("State")
.HasColumnType("int");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.Property<string>("UserName")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId");
b.ToTable("AppUserChatCards");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatFriend", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<bool>("Black")
.HasColumnType("tinyint(1)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("Description")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<bool>("DontDisturb")
.HasColumnType("tinyint(1)");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<Guid>("FrientId")
.HasColumnType("char(36)");
b.Property<string>("RemarkName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<bool>("SpecialFocus")
.HasColumnType("tinyint(1)");
b.Property<byte>("Status")
.HasColumnType("tinyint unsigned");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId", "FrientId");
b.ToTable("AppUserChatFriends");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatSetting", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<bool>("AllowAddFriend")
.HasColumnType("tinyint(1)");
b.Property<bool>("AllowAnonymous")
.HasColumnType("tinyint(1)");
b.Property<bool>("AllowReceiveMessage")
.HasColumnType("tinyint(1)");
b.Property<bool>("AllowSendMessage")
.HasColumnType("tinyint(1)");
b.Property<bool>("RequireAddFriendValition")
.HasColumnType("tinyint(1)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId");
b.ToTable("AppUserChatSettings");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserMessage", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("Content")
.IsRequired()
.HasMaxLength(1048576)
.HasColumnType("longtext");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<long>("MessageId")
.HasColumnType("bigint");
b.Property<Guid>("ReceiveUserId")
.HasColumnType("char(36)");
b.Property<sbyte>("SendState")
.HasColumnType("tinyint");
b.Property<string>("SendUserName")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("varchar(64)");
b.Property<int>("Source")
.HasColumnType("int");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TenantId", "ReceiveUserId");
b.ToTable("AppUserMessages");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.ChatGroup", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<string>("Address")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<Guid>("AdminUserId")
.HasColumnType("char(36)");
b.Property<bool>("AllowAnonymous")
.HasColumnType("tinyint(1)");
b.Property<bool>("AllowSendMessage")
.HasColumnType("tinyint(1)");
b.Property<string>("AvatarUrl")
.HasMaxLength(128)
.HasColumnType("varchar(128)");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("Description")
.HasMaxLength(128)
.HasColumnType("varchar(128)");
b.Property<long>("GroupId")
.HasColumnType("bigint");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<int>("MaxUserCount")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("varchar(20)");
b.Property<string>("Notice")
.HasMaxLength(64)
.HasColumnType("varchar(64)");
b.Property<string>("Tag")
.HasMaxLength(512)
.HasColumnType("varchar(512)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.HasKey("Id");
b.HasIndex("TenantId", "Name");
b.ToTable("AppChatGroups");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupChatBlack", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<long>("GroupId")
.HasColumnType("bigint");
b.Property<Guid>("ShieldUserId")
.HasColumnType("char(36)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.HasKey("Id");
b.HasIndex("TenantId", "GroupId");
b.ToTable("AppGroupChatBlacks");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupMessage", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("Content")
.IsRequired()
.HasMaxLength(1048576)
.HasColumnType("longtext");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<long>("GroupId")
.HasColumnType("bigint");
b.Property<long>("MessageId")
.HasColumnType("bigint");
b.Property<sbyte>("SendState")
.HasColumnType("tinyint");
b.Property<string>("SendUserName")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("varchar(64)");
b.Property<int>("Source")
.HasColumnType("int");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TenantId", "GroupId");
b.ToTable("AppGroupMessages");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserChatGroup", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<long>("GroupId")
.HasColumnType("bigint");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "GroupId", "UserId");
b.ToTable("AppUserChatGroups");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserGroupCard", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<bool>("IsAdmin")
.HasColumnType("tinyint(1)");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<string>("NickName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<DateTime?>("SilenceEnd")
.HasColumnType("datetime(6)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId");
b.ToTable("AppUserGroupCards");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.Notification", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<DateTime?>("ExpirationTime")
.HasColumnType("datetime(6)");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<long>("NotificationId")
.HasColumnType("bigint");
b.Property<string>("NotificationName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<string>("NotificationTypeName")
.IsRequired()
.HasMaxLength(512)
.HasColumnType("varchar(512)");
b.Property<sbyte>("Severity")
.HasColumnType("tinyint");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TenantId", "NotificationName");
b.ToTable("AppNotifications");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.UserNotification", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<long>("NotificationId")
.HasColumnType("bigint");
b.Property<int>("ReadStatus")
.HasColumnType("int");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId", "NotificationId")
.HasDatabaseName("IX_Tenant_User_Notification_Id");
b.ToTable("AppUserNotifications");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Subscriptions.UserSubscribe", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<string>("NotificationName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.Property<string>("UserName")
.IsRequired()
.ValueGeneratedOnAdd()
.HasMaxLength(128)
.HasColumnType("varchar(128)")
.HasDefaultValue("/");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId", "NotificationName")
.IsUnique()
.HasDatabaseName("IX_Tenant_User_Notification_Name");
b.ToTable("AppUserSubscribes");
});
#pragma warning restore 612, 618
}
}
}

35
aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/Migrations/20211111080938_Add-Source-Type-To-Chat-Message.cs

@ -0,0 +1,35 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace LINGYUN.Abp.MessageService.Migrations
{
public partial class AddSourceTypeToChatMessage : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "Source",
table: "AppUserMessages",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "Source",
table: "AppGroupMessages",
type: "int",
nullable: false,
defaultValue: 0);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Source",
table: "AppUserMessages");
migrationBuilder.DropColumn(
name: "Source",
table: "AppGroupMessages");
}
}
}

630
aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/Migrations/20211111221335_Add-Field-Static-To-Chat-Friend.Designer.cs

@ -0,0 +1,630 @@
// <auto-generated />
using System;
using LINGYUN.Abp.MessageService.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Volo.Abp.EntityFrameworkCore;
namespace LINGYUN.Abp.MessageService.Migrations
{
[DbContext(typeof(MessageServiceHostMigrationsDbContext))]
[Migration("20211111221335_Add-Field-Static-To-Chat-Friend")]
partial class AddFieldStaticToChatFriend
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql)
.HasAnnotation("Relational:MaxIdentifierLength", 64)
.HasAnnotation("ProductVersion", "5.0.12");
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatCard", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<int>("Age")
.HasColumnType("int");
b.Property<string>("AvatarUrl")
.HasMaxLength(512)
.HasColumnType("varchar(512)");
b.Property<DateTime?>("Birthday")
.HasColumnType("datetime(6)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("Description")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<DateTime?>("LastOnlineTime")
.HasColumnType("datetime(6)");
b.Property<string>("NickName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<int>("Sex")
.HasColumnType("int");
b.Property<string>("Sign")
.HasMaxLength(30)
.HasColumnType("varchar(30)");
b.Property<int>("State")
.HasColumnType("int");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.Property<string>("UserName")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId");
b.ToTable("AppUserChatCards");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatFriend", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<bool>("Black")
.HasColumnType("tinyint(1)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("Description")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<bool>("DontDisturb")
.HasColumnType("tinyint(1)");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<Guid>("FrientId")
.HasColumnType("char(36)");
b.Property<bool>("IsStatic")
.HasColumnType("tinyint(1)");
b.Property<string>("RemarkName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<bool>("SpecialFocus")
.HasColumnType("tinyint(1)");
b.Property<byte>("Status")
.HasColumnType("tinyint unsigned");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId", "FrientId");
b.ToTable("AppUserChatFriends");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatSetting", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<bool>("AllowAddFriend")
.HasColumnType("tinyint(1)");
b.Property<bool>("AllowAnonymous")
.HasColumnType("tinyint(1)");
b.Property<bool>("AllowReceiveMessage")
.HasColumnType("tinyint(1)");
b.Property<bool>("AllowSendMessage")
.HasColumnType("tinyint(1)");
b.Property<bool>("RequireAddFriendValition")
.HasColumnType("tinyint(1)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId");
b.ToTable("AppUserChatSettings");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserMessage", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("Content")
.IsRequired()
.HasMaxLength(1048576)
.HasColumnType("longtext");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<long>("MessageId")
.HasColumnType("bigint");
b.Property<Guid>("ReceiveUserId")
.HasColumnType("char(36)");
b.Property<sbyte>("SendState")
.HasColumnType("tinyint");
b.Property<string>("SendUserName")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("varchar(64)");
b.Property<int>("Source")
.HasColumnType("int");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TenantId", "ReceiveUserId");
b.ToTable("AppUserMessages");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.ChatGroup", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<string>("Address")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<Guid>("AdminUserId")
.HasColumnType("char(36)");
b.Property<bool>("AllowAnonymous")
.HasColumnType("tinyint(1)");
b.Property<bool>("AllowSendMessage")
.HasColumnType("tinyint(1)");
b.Property<string>("AvatarUrl")
.HasMaxLength(128)
.HasColumnType("varchar(128)");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("Description")
.HasMaxLength(128)
.HasColumnType("varchar(128)");
b.Property<long>("GroupId")
.HasColumnType("bigint");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<int>("MaxUserCount")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("varchar(20)");
b.Property<string>("Notice")
.HasMaxLength(64)
.HasColumnType("varchar(64)");
b.Property<string>("Tag")
.HasMaxLength(512)
.HasColumnType("varchar(512)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.HasKey("Id");
b.HasIndex("TenantId", "Name");
b.ToTable("AppChatGroups");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupChatBlack", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<long>("GroupId")
.HasColumnType("bigint");
b.Property<Guid>("ShieldUserId")
.HasColumnType("char(36)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.HasKey("Id");
b.HasIndex("TenantId", "GroupId");
b.ToTable("AppGroupChatBlacks");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupMessage", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("Content")
.IsRequired()
.HasMaxLength(1048576)
.HasColumnType("longtext");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<long>("GroupId")
.HasColumnType("bigint");
b.Property<long>("MessageId")
.HasColumnType("bigint");
b.Property<sbyte>("SendState")
.HasColumnType("tinyint");
b.Property<string>("SendUserName")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("varchar(64)");
b.Property<int>("Source")
.HasColumnType("int");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TenantId", "GroupId");
b.ToTable("AppGroupMessages");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserChatGroup", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<long>("GroupId")
.HasColumnType("bigint");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "GroupId", "UserId");
b.ToTable("AppUserChatGroups");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserGroupCard", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<bool>("IsAdmin")
.HasColumnType("tinyint(1)");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<string>("NickName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<DateTime?>("SilenceEnd")
.HasColumnType("datetime(6)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId");
b.ToTable("AppUserGroupCards");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.Notification", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<DateTime?>("ExpirationTime")
.HasColumnType("datetime(6)");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<long>("NotificationId")
.HasColumnType("bigint");
b.Property<string>("NotificationName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<string>("NotificationTypeName")
.IsRequired()
.HasMaxLength(512)
.HasColumnType("varchar(512)");
b.Property<sbyte>("Severity")
.HasColumnType("tinyint");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TenantId", "NotificationName");
b.ToTable("AppNotifications");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.UserNotification", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<long>("NotificationId")
.HasColumnType("bigint");
b.Property<int>("ReadStatus")
.HasColumnType("int");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId", "NotificationId")
.HasDatabaseName("IX_Tenant_User_Notification_Id");
b.ToTable("AppUserNotifications");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Subscriptions.UserSubscribe", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<string>("NotificationName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.Property<string>("UserName")
.IsRequired()
.ValueGeneratedOnAdd()
.HasMaxLength(128)
.HasColumnType("varchar(128)")
.HasDefaultValue("/");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId", "NotificationName")
.IsUnique()
.HasDatabaseName("IX_Tenant_User_Notification_Name");
b.ToTable("AppUserSubscribes");
});
#pragma warning restore 612, 618
}
}
}

24
aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/Migrations/20211111221335_Add-Field-Static-To-Chat-Friend.cs

@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace LINGYUN.Abp.MessageService.Migrations
{
public partial class AddFieldStaticToChatFriend : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "IsStatic",
table: "AppUserChatFriends",
type: "tinyint(1)",
nullable: false,
defaultValue: false);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "IsStatic",
table: "AppUserChatFriends");
}
}
}

630
aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/Migrations/20211112083050_Rename-Field-SendState-To-State.Designer.cs

@ -0,0 +1,630 @@
// <auto-generated />
using System;
using LINGYUN.Abp.MessageService.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Volo.Abp.EntityFrameworkCore;
namespace LINGYUN.Abp.MessageService.Migrations
{
[DbContext(typeof(MessageServiceHostMigrationsDbContext))]
[Migration("20211112083050_Rename-Field-SendState-To-State")]
partial class RenameFieldSendStateToState
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql)
.HasAnnotation("Relational:MaxIdentifierLength", 64)
.HasAnnotation("ProductVersion", "5.0.12");
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatCard", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<int>("Age")
.HasColumnType("int");
b.Property<string>("AvatarUrl")
.HasMaxLength(512)
.HasColumnType("varchar(512)");
b.Property<DateTime?>("Birthday")
.HasColumnType("datetime(6)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("Description")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<DateTime?>("LastOnlineTime")
.HasColumnType("datetime(6)");
b.Property<string>("NickName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<int>("Sex")
.HasColumnType("int");
b.Property<string>("Sign")
.HasMaxLength(30)
.HasColumnType("varchar(30)");
b.Property<int>("State")
.HasColumnType("int");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.Property<string>("UserName")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId");
b.ToTable("AppUserChatCards");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatFriend", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<bool>("Black")
.HasColumnType("tinyint(1)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("Description")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<bool>("DontDisturb")
.HasColumnType("tinyint(1)");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<Guid>("FrientId")
.HasColumnType("char(36)");
b.Property<bool>("IsStatic")
.HasColumnType("tinyint(1)");
b.Property<string>("RemarkName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<bool>("SpecialFocus")
.HasColumnType("tinyint(1)");
b.Property<byte>("Status")
.HasColumnType("tinyint unsigned");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId", "FrientId");
b.ToTable("AppUserChatFriends");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatSetting", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<bool>("AllowAddFriend")
.HasColumnType("tinyint(1)");
b.Property<bool>("AllowAnonymous")
.HasColumnType("tinyint(1)");
b.Property<bool>("AllowReceiveMessage")
.HasColumnType("tinyint(1)");
b.Property<bool>("AllowSendMessage")
.HasColumnType("tinyint(1)");
b.Property<bool>("RequireAddFriendValition")
.HasColumnType("tinyint(1)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId");
b.ToTable("AppUserChatSettings");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserMessage", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("Content")
.IsRequired()
.HasMaxLength(1048576)
.HasColumnType("longtext");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<long>("MessageId")
.HasColumnType("bigint");
b.Property<Guid>("ReceiveUserId")
.HasColumnType("char(36)");
b.Property<string>("SendUserName")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("varchar(64)");
b.Property<int>("Source")
.HasColumnType("int");
b.Property<sbyte>("State")
.HasColumnType("tinyint");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TenantId", "ReceiveUserId");
b.ToTable("AppUserMessages");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.ChatGroup", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<string>("Address")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<Guid>("AdminUserId")
.HasColumnType("char(36)");
b.Property<bool>("AllowAnonymous")
.HasColumnType("tinyint(1)");
b.Property<bool>("AllowSendMessage")
.HasColumnType("tinyint(1)");
b.Property<string>("AvatarUrl")
.HasMaxLength(128)
.HasColumnType("varchar(128)");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("Description")
.HasMaxLength(128)
.HasColumnType("varchar(128)");
b.Property<long>("GroupId")
.HasColumnType("bigint");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<int>("MaxUserCount")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("varchar(20)");
b.Property<string>("Notice")
.HasMaxLength(64)
.HasColumnType("varchar(64)");
b.Property<string>("Tag")
.HasMaxLength(512)
.HasColumnType("varchar(512)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.HasKey("Id");
b.HasIndex("TenantId", "Name");
b.ToTable("AppChatGroups");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupChatBlack", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<long>("GroupId")
.HasColumnType("bigint");
b.Property<Guid>("ShieldUserId")
.HasColumnType("char(36)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.HasKey("Id");
b.HasIndex("TenantId", "GroupId");
b.ToTable("AppGroupChatBlacks");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupMessage", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("Content")
.IsRequired()
.HasMaxLength(1048576)
.HasColumnType("longtext");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<long>("GroupId")
.HasColumnType("bigint");
b.Property<long>("MessageId")
.HasColumnType("bigint");
b.Property<string>("SendUserName")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("varchar(64)");
b.Property<int>("Source")
.HasColumnType("int");
b.Property<sbyte>("State")
.HasColumnType("tinyint");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TenantId", "GroupId");
b.ToTable("AppGroupMessages");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserChatGroup", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<long>("GroupId")
.HasColumnType("bigint");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "GroupId", "UserId");
b.ToTable("AppUserChatGroups");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserGroupCard", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<bool>("IsAdmin")
.HasColumnType("tinyint(1)");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<string>("NickName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<DateTime?>("SilenceEnd")
.HasColumnType("datetime(6)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId");
b.ToTable("AppUserGroupCards");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.Notification", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<DateTime?>("ExpirationTime")
.HasColumnType("datetime(6)");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<long>("NotificationId")
.HasColumnType("bigint");
b.Property<string>("NotificationName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<string>("NotificationTypeName")
.IsRequired()
.HasMaxLength(512)
.HasColumnType("varchar(512)");
b.Property<sbyte>("Severity")
.HasColumnType("tinyint");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TenantId", "NotificationName");
b.ToTable("AppNotifications");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.UserNotification", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<long>("NotificationId")
.HasColumnType("bigint");
b.Property<int>("ReadStatus")
.HasColumnType("int");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId", "NotificationId")
.HasDatabaseName("IX_Tenant_User_Notification_Id");
b.ToTable("AppUserNotifications");
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Subscriptions.UserSubscribe", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<string>("NotificationName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.Property<string>("UserName")
.IsRequired()
.ValueGeneratedOnAdd()
.HasMaxLength(128)
.HasColumnType("varchar(128)")
.HasDefaultValue("/");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId", "NotificationName")
.IsUnique()
.HasDatabaseName("IX_Tenant_User_Notification_Name");
b.ToTable("AppUserSubscribes");
});
#pragma warning restore 612, 618
}
}
}

33
aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/Migrations/20211112083050_Rename-Field-SendState-To-State.cs

@ -0,0 +1,33 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace LINGYUN.Abp.MessageService.Migrations
{
public partial class RenameFieldSendStateToState : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "SendState",
table: "AppUserMessages",
newName: "State");
migrationBuilder.RenameColumn(
name: "SendState",
table: "AppGroupMessages",
newName: "State");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "State",
table: "AppUserMessages",
newName: "SendState");
migrationBuilder.RenameColumn(
name: "State",
table: "AppGroupMessages",
newName: "SendState");
}
}
}

866
aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/Migrations/MessageServiceHostMigrationsDbContextModelSnapshot.cs

File diff suppressed because it is too large

4
aspnet-core/tests/LINGYUN.Abp.Notifications.Sms.Tests/LINGYUN/Abp/Notifications/Sms/SmsNotificationDataMapping_Tests.cs

@ -60,7 +60,7 @@ namespace LINGYUN.Abp.Notifications.Sms
mappingStandardData.TryGetData("phoneNumber").ShouldBeNull();
mappingStandardData.TryGetData("template").ShouldBeNull();
mappingStandardData.TryGetData("otherDataKey").ShouldBeNull();
mappingStandardData.Properties.Count.ShouldBe(6);
mappingStandardData.ExtraProperties.Count.ShouldBe(6);
}
[Fact]
@ -76,7 +76,7 @@ namespace LINGYUN.Abp.Notifications.Sms
mappingOriginData.TryGetData(NotificationSmsOptions.TemplateParamsPrefix + "phoneNumber").ShouldNotBeNull();
mappingOriginData.TryGetData(NotificationSmsOptions.TemplateParamsPrefix + "template").ShouldNotBeNull();
mappingOriginData.TryGetData("otherDataKey").ShouldNotBeNull();
mappingOriginData.Properties.Count.ShouldBe(9);
mappingOriginData.ExtraProperties.Count.ShouldBe(9);
}
}
}

4
aspnet-core/tests/LINGYUN.Abp.Notifications.WeChat.MiniProgram.Tests/LINGYUN/Abp/Notifications/WeChat/WeChatMiniProgramNotificationDataMapping_Tests.cs

@ -56,7 +56,7 @@ namespace LINGYUN.Abp.Notifications.WeChat.MiniProgram
// 按照自定义规则,其他数据被丢弃
mappingStandardData.TryGetData("openid").ShouldBeNull();
mappingStandardData.TryGetData("otherDataKey").ShouldBeNull();
mappingStandardData.Properties.Count.ShouldBe(6);
mappingStandardData.ExtraProperties.Count.ShouldBe(6);
}
[Fact]
@ -71,7 +71,7 @@ namespace LINGYUN.Abp.Notifications.WeChat.MiniProgram
// 按照自定义规则,所有数据被保留
mappingOriginData.TryGetData(NotificationWeChatMiniProgramOptions.DefaultMsgPrefix + "openid").ShouldNotBeNull();
mappingOriginData.TryGetData("otherDataKey").ShouldNotBeNull();
mappingOriginData.Properties.Count.ShouldBe(8);
mappingOriginData.ExtraProperties.Count.ShouldBe(8);
}
}
}

Loading…
Cancel
Save