diff --git a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN/Abp/ExceptionHandling/Notifications/AbpExceptionHandlingNotificationDefinitionProvider.cs b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN/Abp/ExceptionHandling/Notifications/AbpExceptionHandlingNotificationDefinitionProvider.cs index effab95a1..4416c951d 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN/Abp/ExceptionHandling/Notifications/AbpExceptionHandlingNotificationDefinitionProvider.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN/Abp/ExceptionHandling/Notifications/AbpExceptionHandlingNotificationDefinitionProvider.cs @@ -24,9 +24,8 @@ namespace LINGYUN.Abp.ExceptionHandling.Notifications .WithProviders( NotificationProviderNames.SignalR, NotificationProviderNames.Emailing) - // 特定的通知提供程序属性 - // 此处为邮件通知定义的模板名称 - .WithProperty("Template", "ExceptionNotifier"); + // 设定为模板通知 + .WithTemplate(typeof(ExceptionHandlingResource)); } protected LocalizableString L(string name) diff --git a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN/Abp/ExceptionHandling/Notifications/AbpNotificationsExceptionSubscriber.cs b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN/Abp/ExceptionHandling/Notifications/AbpNotificationsExceptionSubscriber.cs index cdc027df6..c168dd3fb 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN/Abp/ExceptionHandling/Notifications/AbpNotificationsExceptionSubscriber.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN/Abp/ExceptionHandling/Notifications/AbpNotificationsExceptionSubscriber.cs @@ -2,6 +2,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using System; +using System.Collections.Generic; using System.Threading.Tasks; using Volo.Abp.MultiTenancy; @@ -22,24 +23,21 @@ namespace LINGYUN.Abp.ExceptionHandling.Notifications protected override async Task SendErrorNotifierAsync(ExceptionSendNotifierContext context) { var notificationSender = context.ServiceProvider.GetRequiredService(); - - NotificationData notificationData = new NotificationData(); - // 写入通知数据 - notificationData.TrySetData("header", "An application exception has occurred"); - notificationData.TrySetData("footer", $"Copyright to LY Colin © {DateTime.Now.Year}"); - notificationData.TrySetData("loglevel", context.LogLevel.ToString()); - notificationData.TrySetData("stacktrace", context.Exception.ToString()); - notificationData.WriteStandardData( - context.Exception.GetType().FullName, - context.Exception.Message, - DateTime.Now, - "System"); - + // 发送错误模板消息 await notificationSender.SendNofiterAsync( - AbpExceptionHandlingNotificationNames.NotificationName, - notificationData, + AbpExceptionHandlingNotificationNames.NotificationName, + new NotificationTemplate( + AbpExceptionHandlingNotificationNames.NotificationName, + formUser: "System", + data: new Dictionary + { + { "header", "An application exception has occurred" }, + { "footer", $"Copyright to LY Colin © {DateTime.Now.Year}" }, + { "loglevel", context.LogLevel.ToString() }, + { "stackTrace", context.Exception.ToString() }, + }), user: null, - CurrentTenant.Id, + CurrentTenant.Id, NotificationSeverity.Error); } } diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Emailing/LINGYUN/Abp/Notifications/Emailing/EmailingNotificationPublishProvider.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Emailing/LINGYUN/Abp/Notifications/Emailing/EmailingNotificationPublishProvider.cs index 3a8daa709..8e6306932 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Emailing/LINGYUN/Abp/Notifications/Emailing/EmailingNotificationPublishProvider.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Emailing/LINGYUN/Abp/Notifications/Emailing/EmailingNotificationPublishProvider.cs @@ -1,12 +1,15 @@ using LINGYUN.Abp.Identity; +using LINGYUN.Abp.RealTime.Localization; using Microsoft.Extensions.Localization; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using System; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; using Volo.Abp.Emailing; +using Volo.Abp.Localization; using Volo.Abp.TextTemplating; namespace LINGYUN.Abp.Notifications.Emailing; @@ -17,28 +20,26 @@ public class EmailingNotificationPublishProvider : NotificationPublishProvider public override string Name => ProviderName; - protected IEmailSender EmailSender { get; } + protected AbpLocalizationOptions LocalizationOptions { get; } - protected ITemplateRenderer TemplateRenderer { get; } + protected IEmailSender EmailSender { get; } protected IStringLocalizerFactory LocalizerFactory { get; } protected IIdentityUserRepository UserRepository { get; } - protected INotificationDefinitionManager NotificationDefinitionManager { get; } - public EmailingNotificationPublishProvider( IEmailSender emailSender, ITemplateRenderer templateRenderer, IStringLocalizerFactory localizerFactory, IIdentityUserRepository userRepository, - INotificationDefinitionManager notificationDefinitionManager) + IOptions localizationOptions) { EmailSender = emailSender; - TemplateRenderer = templateRenderer; LocalizerFactory = localizerFactory; UserRepository = userRepository; - NotificationDefinitionManager = notificationDefinitionManager; + + LocalizationOptions = localizationOptions.Value; } protected async override Task PublishAsync( @@ -56,20 +57,30 @@ public class EmailingNotificationPublishProvider : NotificationPublishProvider return; } - var notificationDefinition = NotificationDefinitionManager.Get(notification.Name); - var notificationDisplayName = notificationDefinition.DisplayName.Localize(LocalizerFactory).Value; - - notificationDefinition.Properties.TryGetValue("Template", out var template); - if (template == null) + if (!notification.Data.NeedLocalizer()) { - Logger.LogWarning("The email template is not specified, so the email notification cannot be sent!"); - return; + var title = notification.Data.TryGetData("title").ToString(); + var message = notification.Data.TryGetData("message").ToString(); + + await EmailSender.SendAsync(emailAddress, title, message); } + else + { + var titleInfo = notification.Data.TryGetData("title").As(); + var titleResource = GetResource(titleInfo.ResourceName); + var title = LocalizerFactory.Create(titleResource.ResourceType)[titleInfo.Name, titleInfo.Values].Value; + + var messageInfo = notification.Data.TryGetData("message").As(); + var messageResource = GetResource(messageInfo.ResourceName); + var message = LocalizerFactory.Create(messageResource.ResourceType)[messageInfo.Name, messageInfo.Values].Value; - var content = await TemplateRenderer.RenderAsync( - template.ToString(), - globalContext: notification.Data.ExtraProperties); + await EmailSender.SendAsync(emailAddress, title, message); + } + } - await EmailSender.SendAsync(emailAddress, notificationDisplayName, content); + private LocalizationResource GetResource(string resourceName) + { + return LocalizationOptions.Resources.Values + .First(x => x.ResourceName.Equals(resourceName)); } } diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.TextTemplating/FodyWeavers.xsd b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.TextTemplating/FodyWeavers.xsd new file mode 100644 index 000000000..11da52550 --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.TextTemplating/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.TextTemplating/LINGYUN/Abp/Notifications/TextTemplating/NotificationTemplateContentContributor.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.TextTemplating/LINGYUN/Abp/Notifications/TextTemplating/NotificationTemplateContentContributor.cs index f1708d705..97ec8f2ba 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.TextTemplating/LINGYUN/Abp/Notifications/TextTemplating/NotificationTemplateContentContributor.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.TextTemplating/LINGYUN/Abp/Notifications/TextTemplating/NotificationTemplateContentContributor.cs @@ -9,8 +9,15 @@ public class NotificationTemplateContentContributor : ITemplateContentContributo { public async virtual Task GetOrNullAsync(TemplateContentContributorContext context) { + var notificationDefinitionManager = context.ServiceProvider.GetRequiredService(); + var notification = notificationDefinitionManager.GetOrNull(context.TemplateDefinition.Name); + if (notification == null) + { + return null; + } + var store = context.ServiceProvider.GetRequiredService(); - return await store.GetOrNullAsync(context.TemplateDefinition.Name, context.Culture); + return await store.GetContentOrNullAsync(context.TemplateDefinition.Name, context.Culture); } } diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN.Abp.Notifications.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN.Abp.Notifications.csproj index 206ed4be1..458d3d23a 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN.Abp.Notifications.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN.Abp.Notifications.csproj @@ -1,30 +1,31 @@  - + - - netstandard2.0 - - + + netstandard2.0 + + - - - + + + - - - + + + - - - - - + + + + + + - - - - + + + + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/AbpNotificationModule.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/AbpNotificationModule.cs index cc5860349..730db1bc3 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/AbpNotificationModule.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/AbpNotificationModule.cs @@ -10,6 +10,7 @@ using Volo.Abp.Json; using Volo.Abp.Json.SystemTextJson; using Volo.Abp.Localization; using Volo.Abp.Modularity; +using Volo.Abp.TextTemplating; using Volo.Abp.VirtualFileSystem; namespace LINGYUN.Abp.Notifications @@ -21,7 +22,8 @@ namespace LINGYUN.Abp.Notifications typeof(AbpIdGeneratorModule), typeof(AbpJsonModule), typeof(AbpLocalizationModule), - typeof(AbpRealTimeModule))] + typeof(AbpRealTimeModule), + typeof(AbpTextTemplatingCoreModule))] public class AbpNotificationModule : AbpModule { public override void PreConfigureServices(ServiceConfigurationContext context) @@ -47,6 +49,12 @@ namespace LINGYUN.Abp.Notifications { options.UnsupportedTypes.Add(); }); + + var preActions = context.Services.GetPreConfigureActions(); + Configure(options => + { + preActions.Configure(options); + }); } private void AutoAddDefinitionProviders(IServiceCollection services) @@ -61,10 +69,8 @@ namespace LINGYUN.Abp.Notifications } }); - var preActions = services.GetPreConfigureActions(); Configure(options => { - preActions.Configure(options); options.DefinitionProviders.AddIfNotContains(definitionProviders); }); } diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/AbpNotificationTemplateDefinitionProvider.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/AbpNotificationTemplateDefinitionProvider.cs new file mode 100644 index 000000000..ee203c028 --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/AbpNotificationTemplateDefinitionProvider.cs @@ -0,0 +1,23 @@ +using System.Linq; +using Volo.Abp.TextTemplating; + +namespace LINGYUN.Abp.Notifications; +public class AbpNotificationTemplateDefinitionProvider : TemplateDefinitionProvider +{ + private readonly INotificationDefinitionManager _notificationDefinitionManager; + + public AbpNotificationTemplateDefinitionProvider( + INotificationDefinitionManager notificationDefinitionManager) + { + _notificationDefinitionManager = notificationDefinitionManager; + } + + public override void Define(ITemplateDefinitionContext context) + { + var notifications = _notificationDefinitionManager.GetAll().Where(n => n.Template != null); + foreach (var notification in notifications) + { + context.Add(notification.Template); + } + } +} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/INotificationTemplateStore.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/INotificationTemplateStore.cs index f2a39812e..785df7a31 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/INotificationTemplateStore.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/INotificationTemplateStore.cs @@ -5,5 +5,5 @@ namespace LINGYUN.Abp.Notifications; public interface INotificationTemplateStore { - Task GetOrNullAsync(string templateName, string culture = null, CancellationToken cancellationToken = default); + Task GetContentOrNullAsync(string templateName, string culture = null, CancellationToken cancellationToken = default); } diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NotificationDefinition.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NotificationDefinition.cs index 2a84d9225..f92d28bf5 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NotificationDefinition.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NotificationDefinition.cs @@ -3,12 +3,13 @@ using System; using System.Collections.Generic; using Volo.Abp; using Volo.Abp.Localization; - +using Volo.Abp.TextTemplating; + /* * 2020-10-29 重构通知 * INotificationSender指定接收者,未指定才会查询所有订阅用户,已指定发布者,直接发布(检验是否订阅) - */ - + */ + namespace LINGYUN.Abp.Notifications { public class NotificationDefinition @@ -49,6 +50,10 @@ namespace LINGYUN.Abp.Notifications /// 通知提供者 /// public List Providers { get; } + /// + /// 通知模板 + /// + public TemplateDefinition Template { get; private set; } /// /// 额外属性 /// @@ -84,6 +89,23 @@ namespace LINGYUN.Abp.Notifications return this; } + public virtual NotificationDefinition WithTemplate( + Type localizationResource = null, + bool isLayout = false, + string layout = null, + string defaultCultureName = null) + { + Template = new TemplateDefinition( + Name, + localizationResource, + DisplayName, + isLayout, + layout, + defaultCultureName); + + return this; + } + public virtual NotificationDefinition WithProperty(string key, object value) { Properties[key] = value; diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NotificationTemplate.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NotificationTemplate.cs index e57ee61f9..4b0229554 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NotificationTemplate.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NotificationTemplate.cs @@ -14,7 +14,6 @@ namespace LINGYUN.Abp.Notifications; public class NotificationTemplate : IHasExtraProperties { public string Name { get; set; } - public string Title { get; set; } public string Culture { get; set; } public string FormUser { get; set; } public object this[string key] @@ -27,16 +26,17 @@ public class NotificationTemplate : IHasExtraProperties } } public ExtraPropertyDictionary ExtraProperties { get; set; } + + public NotificationTemplate() { } + public NotificationTemplate( string name, - string title, string culture = null, string formUser = null, IDictionary data = null) { Name = Check.NotNullOrWhiteSpace(name, nameof(name)); - Title = title; Culture = culture; FormUser = formUser; diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NullNotificationTemplateStore.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NullNotificationTemplateStore.cs index f5b4da58c..697aa77b7 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NullNotificationTemplateStore.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NullNotificationTemplateStore.cs @@ -9,7 +9,7 @@ public class NullNotificationTemplateStore : INotificationTemplateStore, ISingle { public readonly static INotificationTemplateStore Instance = new NullNotificationTemplateStore(); - public Task GetOrNullAsync(string templateName, string culture = null, CancellationToken cancellationToken = default) + public Task GetContentOrNullAsync(string templateName, string culture = null, CancellationToken cancellationToken = default) { return Task.FromResult(null); } diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationSendDto.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationSendDto.cs index d0baadb58..a6a9ef506 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationSendDto.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationSendDto.cs @@ -1,5 +1,6 @@ using LINGYUN.Abp.Notifications; using System; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; namespace LINGYUN.Abp.MessageService.Notifications @@ -10,7 +11,9 @@ namespace LINGYUN.Abp.MessageService.Notifications [StringLength(NotificationConsts.MaxNameLength)] public string Name { get; set; } - public NotificationData Data { get; set; } = new NotificationData(); + public Dictionary Data { get; set; } = new Dictionary(); + + public string Culture { get; set; } public Guid? ToUserId { get; set; } diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationTemplateDto.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationTemplateDto.cs new file mode 100644 index 000000000..31ad034ff --- /dev/null +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationTemplateDto.cs @@ -0,0 +1,10 @@ +namespace LINGYUN.Abp.MessageService.Notifications; + +public class NotificationTemplateDto +{ + public string Name { get; set; } + public string Description { get; set; } + public string Title { get; set; } + public string Content { get; set; } + public string Culture { get; set; } +} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationTemplateGetInput.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationTemplateGetInput.cs new file mode 100644 index 000000000..eb7bf5d6f --- /dev/null +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationTemplateGetInput.cs @@ -0,0 +1,11 @@ +using System.ComponentModel.DataAnnotations; + +namespace LINGYUN.Abp.MessageService.Notifications; + +public class NotificationTemplateGetInput +{ + [Required] + public string Name { get; set; } + + public string Culture { get; set; } +} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationTemplateSetInput.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationTemplateSetInput.cs new file mode 100644 index 000000000..adafc3dd6 --- /dev/null +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationTemplateSetInput.cs @@ -0,0 +1,19 @@ +using System.ComponentModel.DataAnnotations; +using Volo.Abp.Validation; + +namespace LINGYUN.Abp.MessageService.Notifications; + +public class NotificationTemplateSetInput +{ + [Required] + [DynamicStringLength(typeof(NotificationTemplateConsts), nameof(NotificationTemplateConsts.MaxNameLength))] + public string Name { get; set; } + + [Required] + [DynamicStringLength(typeof(NotificationTemplateConsts), nameof(NotificationTemplateConsts.MaxCultureLength))] + public string Culture { get; set; } + + [Required] + [DynamicStringLength(typeof(NotificationTemplateConsts), nameof(NotificationTemplateConsts.MaxContentLength))] + public string Content { get; set; } +} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/INotificationAppService.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/INotificationAppService.cs index 3af9843d1..0eb03a414 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/INotificationAppService.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/INotificationAppService.cs @@ -1,9 +1,16 @@ using System.Threading.Tasks; - +using Volo.Abp.Application.Dtos; + namespace LINGYUN.Abp.MessageService.Notifications { public interface INotificationAppService { + Task SetTemplateAsync(NotificationTemplateSetInput input); + + Task GetTemplateAsync(NotificationTemplateGetInput input); + + Task> GetAssignableTemplatesAsync(); + Task SendAsync(NotificationSendDto input); } } diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/AbpMessageServiceApplicationAutoMapperProfile.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/AbpMessageServiceApplicationAutoMapperProfile.cs index 363e6aa80..ef4e5b505 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/AbpMessageServiceApplicationAutoMapperProfile.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/AbpMessageServiceApplicationAutoMapperProfile.cs @@ -23,6 +23,8 @@ namespace LINGYUN.Abp.MessageService } return new NotificationData(); })); + + CreateMap(); } } } diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Notifications/MyNotificationAppService.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Notifications/MyNotificationAppService.cs index 5427776d5..6f485af7a 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Notifications/MyNotificationAppService.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Notifications/MyNotificationAppService.cs @@ -31,22 +31,6 @@ namespace LINGYUN.Abp.MessageService.Notifications NotificationDefinitionManager = notificationDefinitionManager; } - public async virtual Task SendNofiterAsync(NotificationSendDto input) - { - UserIdentifier user = null; - if (input.ToUserId.HasValue) - { - user = new UserIdentifier(input.ToUserId.Value, input.ToUserName); - } - await NotificationSender - .SendNofiterAsync( - input.Name, - input.Data, - user, - CurrentTenant.Id, - input.Severity); - } - public async virtual Task MarkReadStateAsync(NotificationMarkReadStateInput input) { await NotificationStore.ChangeUserNotificationsReadStateAsync( diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Notifications/NotificationAppService.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Notifications/NotificationAppService.cs index 7ffe5a310..512a76928 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Notifications/NotificationAppService.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Notifications/NotificationAppService.cs @@ -1,35 +1,137 @@ using LINGYUN.Abp.Notifications; using Microsoft.AspNetCore.Authorization; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; - +using Volo.Abp.TextTemplating; + namespace LINGYUN.Abp.MessageService.Notifications { [Authorize] public class NotificationAppService : ApplicationService, INotificationAppService { + protected ITemplateContentProvider TemplateContentProvider { get; } protected INotificationSender NotificationSender { get; } + protected INotificationDefinitionManager NotificationDefinitionManager { get; } + protected INotificationTemplateRepository NotificationTemplateRepository { get; } public NotificationAppService( - INotificationSender notificationSender) + INotificationSender notificationSender, + ITemplateContentProvider templateContentProvider, + INotificationDefinitionManager notificationDefinitionManager, + INotificationTemplateRepository notificationTemplateRepository) { NotificationSender = notificationSender; + TemplateContentProvider = templateContentProvider; + NotificationDefinitionManager = notificationDefinitionManager; + NotificationTemplateRepository = notificationTemplateRepository; + } + + public async virtual Task SetTemplateAsync(NotificationTemplateSetInput input) + { + var notification = GetNotificationDefinition(input.Name); + + var template = await NotificationTemplateRepository.GetByNameAsync(input.Name, input.Culture); + if (template == null) + { + template = new NotificationTemplate( + GuidGenerator.Create(), + notification.Name, + notification.DisplayName.Localize(StringLocalizerFactory), + input.Content, + input.Culture, + notification.Description?.Localize(StringLocalizerFactory)); + + template = await NotificationTemplateRepository.InsertAsync(template); + } + else + { + template.SetContent(input.Content); + + await NotificationTemplateRepository.UpdateAsync(template); + } + + await CurrentUnitOfWork.SaveChangesAsync(); + + return ObjectMapper.Map(template); } - public virtual async Task SendAsync(NotificationSendDto input) + public async virtual Task GetTemplateAsync(NotificationTemplateGetInput input) + { + var notification = GetNotificationDefinition(input.Name); + + var culture = input.Culture ?? CultureInfo.CurrentCulture.Name; + var content = await TemplateContentProvider.GetContentOrNullAsync(notification.Name, culture); + + return new NotificationTemplateDto + { + Culture = culture, + Content = content, + Name = notification.Name, + Title = notification.DisplayName.Localize(StringLocalizerFactory), + Description = notification.Description?.Localize(StringLocalizerFactory), + }; + } + + public virtual Task> GetAssignableTemplatesAsync() + { + var templates = new List(); + var notifications = NotificationDefinitionManager.GetAll().Where(n => n.Template != null); + + foreach (var notification in notifications) + { + templates.Add( + new NotificationTemplateDto + { + Name = notification.Name, + Culture = CultureInfo.CurrentCulture.Name, + Title = notification.DisplayName.Localize(StringLocalizerFactory), + Description = notification.Description?.Localize(StringLocalizerFactory), + }); + } + + return Task.FromResult(new ListResultDto(templates)); + } + + public async virtual Task SendAsync(NotificationSendDto input) { + var notification = GetNotificationDefinition(input.Name); + UserIdentifier user = null; if (input.ToUserId.HasValue) { user = new UserIdentifier(input.ToUserId.Value, input.ToUserName); } + await NotificationSender .SendNofiterAsync( - input.Name, - input.Data, - user, + name: input.Name, + template: new Abp.Notifications.NotificationTemplate( + notification.Name, + culture: input.Culture ?? CultureInfo.CurrentCulture.Name, + formUser: CurrentUser.Name ?? CurrentUser.UserName, + data: input.Data), + user: user, CurrentTenant.Id, input.Severity); } + + protected virtual NotificationDefinition GetNotificationDefinition(string name) + { + var notification = NotificationDefinitionManager.GetOrNull(name); + if (notification == null || notification.Template == null) + { + throw new BusinessException( + MessageServiceErrorCodes.NotificationTemplateNotFound, + $"The notification template {name} does not exist!") + .WithData("Name", name); + } + + return notification; + } } } diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Localization/Resources/en.json b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Localization/Resources/en.json index a18782a54..d6210d8bc 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Localization/Resources/en.json +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Localization/Resources/en.json @@ -18,6 +18,7 @@ "LINGYUN.Abp.Message:03404": "Sending the message failed: the user does not exist or is deactivated!", "LINGYUN.Abp.Message:03410": "Users refuse to add friends", "LINGYUN.Abp.Message:03411": "The other party is already your friend or has sent an authentication request. The operation cannot be repeated!", + "LINGYUN.Abp.Message:05404": "The notification template does not exist!", "MarkSelectedAsRead": "Mark selected as read", "MarkAs": "Mark as", "Read": "Read", diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Localization/Resources/zh-Hans.json b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Localization/Resources/zh-Hans.json index d9435eaaf..f716290e2 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Localization/Resources/zh-Hans.json +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Localization/Resources/zh-Hans.json @@ -18,6 +18,7 @@ "LINGYUN.Abp.Message:03404": "发送消息失败: 用户不存在或已注销账号!", "LINGYUN.Abp.Message:03410": "用户拒绝添加好友", "LINGYUN.Abp.Message:03411": "对方已是您的好友或已发送验证请求,不能重复操作!", + "LINGYUN.Abp.Message:05404": "通知模板不存在!", "MarkSelectedAsRead": "标记选中已读", "MarkAs": "标记为", "Read": "已读", diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/MessageServiceErrorCodes.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/MessageServiceErrorCodes.cs index 1245784b2..b7afe06bc 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/MessageServiceErrorCodes.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/MessageServiceErrorCodes.cs @@ -99,5 +99,9 @@ /// 你需要验证问题才能添加好友 /// public const string YouNeedValidationQuestingByAddFriend = Namespace + ":03302"; + /// + /// 通知模板不存在! + /// + public const string NotificationTemplateNotFound = Namespace + ":05404"; } } diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Notifications/NotificationTemplateConsts.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Notifications/NotificationTemplateConsts.cs new file mode 100644 index 000000000..27c74e900 --- /dev/null +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Notifications/NotificationTemplateConsts.cs @@ -0,0 +1,14 @@ +namespace LINGYUN.Abp.MessageService.Notifications; + +public static class NotificationTemplateConsts +{ + public static int MaxNameLength { get; set; } = 100; + + public static int MaxTitleLength { get; set; } = 100; + + public static int MaxContentLength { get; set; } = 1024 * 1024; + + public static int MaxDescriptionLength { get; set; } = 255; + + public static int MaxCultureLength { get; set; } = 30; +} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/MessageServiceDomainAutoMapperProfile.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/MessageServiceDomainAutoMapperProfile.cs index 847c20072..39846ad48 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/MessageServiceDomainAutoMapperProfile.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/MessageServiceDomainAutoMapperProfile.cs @@ -17,6 +17,25 @@ namespace LINGYUN.Abp.MessageService.Mapper { public MessageServiceDomainAutoMapperProfile() { + CreateMap() + .ForMember(dto => dto.Id, map => map.MapFrom(src => src.NotificationId.ToString())) + .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.CreationTime, map => map.MapFrom(src => src.CreationTime)) + .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() .ForMember(dto => dto.Id, map => map.MapFrom(src => src.Id.ToString())) .ForMember(dto => dto.Name, map => map.MapFrom(src => src.Name)) diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/AbpMessageServiceNotificationDefinitionProvider.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/AbpMessageServiceNotificationDefinitionProvider.cs index 1eff5042c..f1ab03432 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/AbpMessageServiceNotificationDefinitionProvider.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/AbpMessageServiceNotificationDefinitionProvider.cs @@ -26,7 +26,7 @@ namespace LINGYUN.Abp.MessageService.Notifications .WithProviders( NotificationProviderNames.SignalR, NotificationProviderNames.Emailing) - .WithProperty("Template", "NewTenantRegisterd"); + .WithTemplate(typeof(MessageServiceResource)); var usersGroup = context.AddGroup( UserNotificationNames.GroupName, @@ -42,7 +42,7 @@ namespace LINGYUN.Abp.MessageService.Notifications .WithProviders( NotificationProviderNames.SignalR, NotificationProviderNames.Emailing) - .WithProperty("Template", "WelcomeToApplication"); + .WithTemplate(typeof(MessageServiceResource)); var imGroup = context.AddGroup( MessageServiceNotificationNames.IM.GroupName, diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/INotificationTemplateRepository.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/INotificationTemplateRepository.cs new file mode 100644 index 000000000..a5915dd08 --- /dev/null +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/INotificationTemplateRepository.cs @@ -0,0 +1,11 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories; + +namespace LINGYUN.Abp.MessageService.Notifications; + +public interface INotificationTemplateRepository : IBasicRepository +{ + Task GetByNameAsync(string name, string culture = null, CancellationToken cancellationToken = default); +} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationTemplate.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationTemplate.cs index 0011079cf..3fd0f56ce 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationTemplate.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationTemplate.cs @@ -1,11 +1,37 @@ using System; -using System.Collections.Generic; -using System.Text; +using Volo.Abp; using Volo.Abp.Domain.Entities.Auditing; +using Volo.Abp.MultiTenancy; namespace LINGYUN.Abp.MessageService.Notifications; -public class NotificationTemplate : AuditedAggregateRoot +public class NotificationTemplate : AuditedEntity, IMultiTenant { + public virtual Guid? TenantId { get; protected set; } + public virtual string Name { get; private set; } + public virtual string Description { get; private set; } + public virtual string Title { get; private set; } + public virtual string Content { get; private set; } + public virtual string Culture { get; private set; } + protected NotificationTemplate() { } + public NotificationTemplate( + Guid id, + string name, + string title, + string content, + string culture, + string description = null) + : base(id) + { + Name = Check.NotNullOrWhiteSpace(name, nameof(name), NotificationTemplateConsts.MaxNameLength); + Title = Check.NotNullOrWhiteSpace(title, nameof(title), NotificationTemplateConsts.MaxTitleLength); + Content = Check.NotNullOrWhiteSpace(content, nameof(content), NotificationTemplateConsts.MaxContentLength); + Culture = Check.NotNullOrWhiteSpace(culture, nameof(culture), NotificationTemplateConsts.MaxCultureLength); + Description = Check.Length(description, nameof(description), NotificationTemplateConsts.MaxDescriptionLength); + } + public void SetContent(string content) + { + Content = Check.NotNullOrWhiteSpace(content, nameof(content), NotificationTemplateConsts.MaxContentLength); + } } diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationTemplateStore.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationTemplateStore.cs new file mode 100644 index 000000000..ae96c5cb0 --- /dev/null +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationTemplateStore.cs @@ -0,0 +1,31 @@ +using LINGYUN.Abp.Notifications; +using Microsoft.Extensions.DependencyInjection; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; + +namespace LINGYUN.Abp.MessageService.Notifications; + +[Dependency(ServiceLifetime.Transient, ReplaceServices = true)] +[ExposeServices(typeof(INotificationTemplateStore))] +public class NotificationTemplateStore : INotificationTemplateStore +{ + protected INotificationTemplateRepository NotificationTemplateRepository { get; } + + public NotificationTemplateStore( + INotificationTemplateRepository notificationTemplateRepository) + { + NotificationTemplateRepository = notificationTemplateRepository; + } + + public async virtual Task GetContentOrNullAsync(string templateName, string culture = null, CancellationToken cancellationToken = default) + { + var template = await NotificationTemplateRepository.GetByNameAsync( + templateName, + culture ?? CultureInfo.CurrentCulture.Name, + cancellationToken); + + return template?.Content; + } +} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/AbpMessageServiceEntityFrameworkCoreModule.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/AbpMessageServiceEntityFrameworkCoreModule.cs index 13175a1a1..8a7e6a218 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/AbpMessageServiceEntityFrameworkCoreModule.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/AbpMessageServiceEntityFrameworkCoreModule.cs @@ -18,6 +18,8 @@ namespace LINGYUN.Abp.MessageService.EntityFrameworkCore context.Services.AddAbpDbContext(options => { options.AddRepository(); + options.AddRepository(); + options.AddRepository(); options.AddRepository(); diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContextModelCreatingExtensions.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContextModelCreatingExtensions.cs index 26e6945b6..37bb47258 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContextModelCreatingExtensions.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContextModelCreatingExtensions.cs @@ -34,6 +34,23 @@ namespace LINGYUN.Abp.MessageService.EntityFrameworkCore b.HasIndex(p => new { p.TenantId, p.NotificationName }); }); + builder.Entity(b => + { + b.ToTable(options.TablePrefix + "NotificationTemplates", options.Schema); + + b.Property(p => p.Name).HasMaxLength(NotificationTemplateConsts.MaxNameLength).IsRequired(); + b.Property(p => p.Title).HasMaxLength(NotificationTemplateConsts.MaxTitleLength).IsRequired(); + b.Property(p => p.Content).HasMaxLength(NotificationTemplateConsts.MaxContentLength).IsRequired(); + b.Property(p => p.Culture).HasMaxLength(NotificationTemplateConsts.MaxCultureLength).IsRequired(); + + b.Property(p => p.Description).HasMaxLength(NotificationTemplateConsts.MaxDescriptionLength); + + b.ConfigureByConvention(); + + b.HasIndex(p => new { p.TenantId, p.Name }) + .HasDatabaseName("IX_Tenant_Notification_Template_Name"); + }); + builder.Entity(b => { b.ToTable(options.TablePrefix + "UserNotifications", options.Schema); diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreNotificationTemplateRepository.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreNotificationTemplateRepository.cs new file mode 100644 index 000000000..249722274 --- /dev/null +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreNotificationTemplateRepository.cs @@ -0,0 +1,32 @@ +using LINGYUN.Abp.MessageService.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Domain.Repositories.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore; + +namespace LINGYUN.Abp.MessageService.Notifications; + +public class EfCoreNotificationTemplateRepository : + EfCoreRepository, + INotificationTemplateRepository, + ITransientDependency +{ + public EfCoreNotificationTemplateRepository( + IDbContextProvider dbContextProvider) + : base(dbContextProvider) + { + } + + public async virtual Task GetByNameAsync(string name, string culture = null, CancellationToken cancellationToken = default) + { + return await (await GetDbSetAsync()) + .Where(x => x.Name.Equals(name)) + .WhereIf(!culture.IsNullOrWhiteSpace(), x => x.Culture.Equals(culture)) + .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); + } +} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN/Abp/MessageService/Notifications/NotificationController.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN/Abp/MessageService/Notifications/NotificationController.cs index c92a54ec7..192bd309c 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN/Abp/MessageService/Notifications/NotificationController.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN/Abp/MessageService/Notifications/NotificationController.cs @@ -1,10 +1,13 @@ -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; using System.Threading.Tasks; using Volo.Abp; +using Volo.Abp.Application.Dtos; using Volo.Abp.AspNetCore.Mvc; namespace LINGYUN.Abp.MessageService.Notifications { + [Authorize] [RemoteService(Name = AbpMessageServiceConsts.RemoteServiceName)] [Route("api/notifilers")] public class NotificationController : AbpController, INotificationAppService @@ -18,9 +21,31 @@ namespace LINGYUN.Abp.MessageService.Notifications } [HttpPost] - public virtual async Task SendAsync(NotificationSendDto input) + public async virtual Task SendAsync(NotificationSendDto input) { await NotificationAppService.SendAsync(input); } + + [HttpPost] + [Route("templates")] + public async virtual Task SetTemplateAsync(NotificationTemplateSetInput input) + { + return await NotificationAppService.SetTemplateAsync(input); + } + + [HttpGet] + [Route("templates/{Name}")] + [Route("templates/{Culture}/{Name}")] + public async virtual Task GetTemplateAsync(NotificationTemplateGetInput input) + { + return await NotificationAppService.GetTemplateAsync(input); + } + + [HttpGet] + [Route("templates")] + public async virtual Task> GetAssignableTemplatesAsync() + { + return await NotificationAppService.GetAssignableTemplatesAsync(); + } } } diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/RealtimeMessageTemplateProvider.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/RealtimeMessageTemplateProvider.cs index 84a30254d..e6b143b00 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/RealtimeMessageTemplateProvider.cs +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/RealtimeMessageTemplateProvider.cs @@ -1,5 +1,8 @@ -using Volo.Abp.TextTemplating; +using LINGYUN.Abp.ExceptionHandling.Notifications; +using Volo.Abp.MultiTenancy; +using Volo.Abp.TextTemplating; using Volo.Abp.TextTemplating.Scriban; +using Volo.Abp.Users; namespace LY.MicroService.RealtimeMessage.Emailing; @@ -8,6 +11,38 @@ public class RealtimeMessageTemplateProvider : TemplateDefinitionProvider public override void Define(ITemplateDefinitionContext context) { context.Add(CreateEmailTemplate()); + + ReplaceDefaultTemplatePath(context); + } + + protected virtual void ReplaceDefaultTemplatePath(ITemplateDefinitionContext context) + { + var exceptionTemplate = context.GetOrNull(AbpExceptionHandlingNotificationNames.NotificationName); + if (exceptionTemplate != null) + { + exceptionTemplate + .WithScribanEngine() + .WithVirtualFilePath("/Emailing/Templates/ExceptionNotifier", isInlineLocalized: false) + .Layout = "EmailNotifierLayout"; + } + + var tenantRegisterdTemplate = context.GetOrNull(TenantNotificationNames.NewTenantRegistered); + if (tenantRegisterdTemplate != null) + { + tenantRegisterdTemplate + .WithScribanEngine() + .WithVirtualFilePath("/Emailing/Templates/NewTenantRegisterd", isInlineLocalized: false) + .Layout = "EmailNotifierLayout"; + } + + var welcomeToApplicationTemplate = context.GetOrNull(UserNotificationNames.WelcomeToApplication); + if (welcomeToApplicationTemplate != null) + { + welcomeToApplicationTemplate + .WithScribanEngine() + .WithVirtualFilePath("/Emailing/Templates/WelcomeToApplication", isInlineLocalized: false) + .Layout = "EmailNotifierLayout"; + } } protected virtual TemplateDefinition[] CreateEmailTemplate() @@ -18,34 +53,8 @@ public class RealtimeMessageTemplateProvider : TemplateDefinitionProvider name: "EmailNotifierLayout", defaultCultureName: "en", isLayout: true) - .WithScribanEngine() - .WithVirtualFilePath( - "/Emailing/Templates/layout.tpl", - isInlineLocalized: false), - new TemplateDefinition( - name: "ExceptionNotifier", - defaultCultureName: "en", - layout: "EmailNotifierLayout") - .WithScribanEngine() - .WithVirtualFilePath( - "/Emailing/Templates/ExceptionNotifier", - isInlineLocalized: false), - new TemplateDefinition( - "NewTenantRegisterd", - defaultCultureName: "en", - layout: "EmailNotifierLayout") - .WithScribanEngine() - .WithVirtualFilePath( - "/Emailing/Templates/NewTenantRegisterd", - isInlineLocalized: false), - new TemplateDefinition( - "WelcomeToApplication", - defaultCultureName: "en", - layout: "EmailNotifierLayout") - .WithScribanEngine() - .WithVirtualFilePath( - "/Emailing/Templates/WelcomeToApplication", - isInlineLocalized: false), + .WithScribanEngine() + .WithVirtualFilePath( "/Emailing/Templates/layout.tpl", isInlineLocalized: true), }; } } diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/ExceptionNotifier/en.tpl b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/ExceptionNotifier/en.tpl index 38d937243..96adba531 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/ExceptionNotifier/en.tpl +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/ExceptionNotifier/en.tpl @@ -1,17 +1,17 @@  @@ -23,14 +23,14 @@ diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/ExceptionNotifier/zh-Hans.tpl b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/ExceptionNotifier/zh-Hans.tpl index 3d4b1e53d..d722e6e6f 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/ExceptionNotifier/zh-Hans.tpl +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/ExceptionNotifier/zh-Hans.tpl @@ -1,17 +1,18 @@ 
-
{{ header }} +
{{ model.header }}
    -
  • Type  : {{ type }}
  • -
  • Message  : {{ message }}
  • -
  • Alarm level : {{ loglevel }}
  • -
  • TriggerTime : {{ createTime }}
  • +
  • Type  : {{ model.type }}
  • +
  • Message  : {{ model.message }}
  • +
  • Alarm level : {{ model.loglevel }}
  • +
  • TriggerTime : {{ creationTime }}
-
{{ stacktrace }}
+
{{ model.stackTrace }}


- {{ footer }} + {{ model.footer }}
@@ -23,14 +24,14 @@ diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/NewTenantRegisterd/en.tpl b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/NewTenantRegisterd/en.tpl index 959d97561..7dc4cf5a8 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/NewTenantRegisterd/en.tpl +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/NewTenantRegisterd/en.tpl @@ -1 +1 @@ -

A new tenant {{name}} has been created.

\ No newline at end of file +

A new tenant {{model.name}} has been created.

\ No newline at end of file diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/NewTenantRegisterd/zh-Hans.tpl b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/NewTenantRegisterd/zh-Hans.tpl index 25f545dc8..b00146366 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/NewTenantRegisterd/zh-Hans.tpl +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/NewTenantRegisterd/zh-Hans.tpl @@ -1 +1 @@ -

一个新的租户 {{name}} 已建立,切换租户开始!

\ No newline at end of file +

一个新的租户 {{model.name}} 已建立,切换租户开始!

\ No newline at end of file diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/WelcomeToApplication/en.tpl b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/WelcomeToApplication/en.tpl index 2f5fa7959..5ef5dc0e7 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/WelcomeToApplication/en.tpl +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/WelcomeToApplication/en.tpl @@ -1 +1 @@ -

{{user}}, Welcome to my application!

\ No newline at end of file +

{{model.name}}, Welcome to my application!

\ No newline at end of file diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/WelcomeToApplication/zh-Hans.tpl b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/WelcomeToApplication/zh-Hans.tpl index 2f5fa7959..78c40dc93 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/WelcomeToApplication/zh-Hans.tpl +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/WelcomeToApplication/zh-Hans.tpl @@ -1 +1 @@ -

{{user}}, Welcome to my application!

\ No newline at end of file +

{{model.name}}, 欢迎您的加入!

\ No newline at end of file diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Distributed/NotificationEventHandler.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Distributed/NotificationEventHandler.cs index cb33ada0c..08bef0bfb 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Distributed/NotificationEventHandler.cs +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Distributed/NotificationEventHandler.cs @@ -118,23 +118,28 @@ namespace LY.MicroService.RealtimeMessage.EventBus.Distributed var notificationInfo = new NotificationInfo { Name = notification.Name, - CreationTime = eventData.CreationTime, + TenantId = eventData.TenantId, Severity = eventData.Severity, + Type = notification.NotificationType, + CreationTime = eventData.CreationTime, Lifetime = notification.NotificationLifetime, - TenantId = eventData.TenantId, - Type = notification.NotificationType }; notificationInfo.SetId(eventData.Id); - var title = eventData.Data.Title; - if (title.IsNullOrWhiteSpace()) - { - title = notification.DisplayName.Localize(StringLocalizerFactory); - } + var title = notification.DisplayName.Localize(StringLocalizerFactory); + var message = await TemplateRenderer.RenderAsync( templateName: eventData.Data.Name, + model: eventData.Data.ExtraProperties, cultureName: eventData.Data.Culture, - globalContext: eventData.Data.ExtraProperties); + globalContext: new Dictionary + { + { "notification", notification.Name }, + { "formUser", eventData.Data.FormUser }, + { "notificationId", eventData.Id }, + { "title", title.ToString() }, + { "creationTime", eventData.CreationTime.ToString("yyyy-MM-dd HH:mm:ss") }, + }); var notificationData = new NotificationData(); notificationData.WriteStandardData( @@ -142,6 +147,7 @@ namespace LY.MicroService.RealtimeMessage.EventBus.Distributed message: message, createTime: eventData.CreationTime, formUser: eventData.Data.FormUser); + notificationData.ExtraProperties.AddIfNotContains(eventData.Data.ExtraProperties); notificationInfo.Data = notificationData; diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Distributed/TenantSynchronizer.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Distributed/TenantSynchronizer.cs index 276b618fa..51feb987e 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Distributed/TenantSynchronizer.cs +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Distributed/TenantSynchronizer.cs @@ -81,34 +81,22 @@ namespace LY.MicroService.RealtimeMessage.EventBus.Distributed tenantAdminUserIdentifier, TenantNotificationNames.NewTenantRegistered); - var notificationData = new NotificationData(); - notificationData.TrySetData("name", eventData.Name); - notificationData.WriteLocalizedData( - new LocalizableStringInfo( - LocalizationResourceNameAttribute.GetName(typeof(MessageServiceResource)), - "NewTenantRegisteredNotificationTitle", - new Dictionary - { - { "Name", eventData.Name }, - }), - new LocalizableStringInfo( - LocalizationResourceNameAttribute.GetName(typeof(MessageServiceResource)), - "NewTenantRegisteredNotificationMessage", - new Dictionary + Logger.LogInformation("publish new tenant notification.."); + await NotificationSender.SendNofiterAsync( + TenantNotificationNames.NewTenantRegistered, + new NotificationTemplate( + TenantNotificationNames.NewTenantRegistered, + formUser: eventData.AdminEmailAddress, + data: new Dictionary { - { "Name", eventData.Name} + { "name", eventData.Name }, + { "email", eventData.AdminEmailAddress }, + { "id", eventData.Id }, }), - DateTime.Now, eventData.AdminEmailAddress); + tenantAdminUserIdentifier, + eventData.Id, + NotificationSeverity.Success); - Logger.LogInformation("publish new tenant notification.."); - // 发布租户创建通知 - await NotificationSender - .SendNofiterAsync( - TenantNotificationNames.NewTenantRegistered, - notificationData, - tenantAdminUserIdentifier, - eventData.Id, - NotificationSeverity.Success); Logger.LogInformation("tenant administrator subscribes to new tenant events.."); } catch(Exception ex) diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Local/UserCreateSendWelcomeEventHandler.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Local/UserCreateSendWelcomeEventHandler.cs index 1075b7daa..978639fba 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Local/UserCreateSendWelcomeEventHandler.cs +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Local/UserCreateSendWelcomeEventHandler.cs @@ -1,13 +1,10 @@ -using LINGYUN.Abp.MessageService.Localization; -using LINGYUN.Abp.Notifications; -using LINGYUN.Abp.RealTime.Localization; +using LINGYUN.Abp.Notifications; using System; using System.Collections.Generic; using System.Threading.Tasks; using Volo.Abp.DependencyInjection; using Volo.Abp.Domain.Entities.Events; using Volo.Abp.EventBus; -using Volo.Abp.Localization; using Volo.Abp.Users; namespace LY.MicroService.RealtimeMessage.EventBus @@ -31,35 +28,18 @@ namespace LY.MicroService.RealtimeMessage.EventBus // 订阅用户欢迎消息 await SubscribeInternalNotifers(userIdentifer, eventData.Entity.TenantId); - var userWelcomeNotifictionData = new NotificationData(); - - userWelcomeNotifictionData.TrySetData("user", eventData.Entity.UserName); - userWelcomeNotifictionData - .WriteLocalizedData( - new LocalizableStringInfo( - LocalizationResourceNameAttribute.GetName(typeof(MessageServiceResource)), - "WelcomeToApplicationFormUser", - new Dictionary - { - { "User", eventData.Entity.UserName } - }), - new LocalizableStringInfo( - LocalizationResourceNameAttribute.GetName(typeof(MessageServiceResource)), - "WelcomeToApplicationFormUser", - new Dictionary + await _notificationSender.SendNofiterAsync( + UserNotificationNames.WelcomeToApplication, + new NotificationTemplate( + UserNotificationNames.WelcomeToApplication, + formUser: eventData.Entity.UserName, + data: new Dictionary { - { "User", eventData.Entity.UserName } + { "name", eventData.Entity.UserName }, }), - DateTime.Now, eventData.Entity.UserName); - - await _notificationSender - .SendNofiterAsync( - UserNotificationNames.WelcomeToApplication, - userWelcomeNotifictionData, userIdentifer, - eventData.Entity.TenantId, - NotificationSeverity.Info - ); + eventData.Entity.Id, + NotificationSeverity.Info); } private async Task SubscribeInternalNotifers(UserIdentifier userIdentifer, Guid? tenantId = null) diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj index eabf4f0d1..8ffbad998 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj @@ -9,7 +9,7 @@ - + @@ -55,6 +55,7 @@ + diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Migrations/20220624035652_Add-Entity-Notification-Template.Designer.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Migrations/20220624035652_Add-Entity-Notification-Template.Designer.cs new file mode 100644 index 000000000..8e8b83479 --- /dev/null +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Migrations/20220624035652_Add-Entity-Notification-Template.Designer.cs @@ -0,0 +1,690 @@ +// +using System; +using LY.MicroService.RealtimeMessage.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace LY.MicroService.RealtimeMessage.Migrations +{ + [DbContext(typeof(RealtimeMessageMigrationsDbContext))] + [Migration("20220624035652_Add-Entity-Notification-Template")] + partial class AddEntityNotificationTemplate + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "6.0.6") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatCard", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Age") + .HasColumnType("int"); + + b.Property("AvatarUrl") + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("Birthday") + .HasColumnType("datetime(6)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("Description") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("LastOnlineTime") + .HasColumnType("datetime(6)"); + + b.Property("NickName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("Sex") + .HasColumnType("int"); + + b.Property("Sign") + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("State") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("UserName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId"); + + b.ToTable("AppUserChatCards", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatFriend", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Black") + .HasColumnType("tinyint(1)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("Description") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("DontDisturb") + .HasColumnType("tinyint(1)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("FrientId") + .HasColumnType("char(36)"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)"); + + b.Property("RemarkName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("SpecialFocus") + .HasColumnType("tinyint(1)"); + + b.Property("Status") + .HasColumnType("tinyint unsigned"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId", "FrientId"); + + b.ToTable("AppUserChatFriends", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatSetting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AllowAddFriend") + .HasColumnType("tinyint(1)"); + + b.Property("AllowAnonymous") + .HasColumnType("tinyint(1)"); + + b.Property("AllowReceiveMessage") + .HasColumnType("tinyint(1)"); + + b.Property("AllowSendMessage") + .HasColumnType("tinyint(1)"); + + b.Property("RequireAddFriendValition") + .HasColumnType("tinyint(1)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId"); + + b.ToTable("AppUserChatSettings", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(1048576) + .HasColumnType("longtext"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("MessageId") + .HasColumnType("bigint"); + + b.Property("ReceiveUserId") + .HasColumnType("char(36)"); + + b.Property("SendUserName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Source") + .HasColumnType("int"); + + b.Property("State") + .HasColumnType("tinyint"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "ReceiveUserId"); + + b.ToTable("AppUserMessages", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.ChatGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Address") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("AdminUserId") + .HasColumnType("char(36)"); + + b.Property("AllowAnonymous") + .HasColumnType("tinyint(1)"); + + b.Property("AllowSendMessage") + .HasColumnType("tinyint(1)"); + + b.Property("AvatarUrl") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("Description") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("MaxUserCount") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("Notice") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Tag") + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Name"); + + b.ToTable("AppChatGroups", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupChatBlack", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("ShieldUserId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "GroupId"); + + b.ToTable("AppGroupChatBlacks", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(1048576) + .HasColumnType("longtext"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("MessageId") + .HasColumnType("bigint"); + + b.Property("SendUserName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Source") + .HasColumnType("int"); + + b.Property("State") + .HasColumnType("tinyint"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "GroupId"); + + b.ToTable("AppGroupMessages", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserChatGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "GroupId", "UserId"); + + b.ToTable("AppUserChatGroups", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserGroupCard", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsAdmin") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("NickName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("SilenceEnd") + .HasColumnType("datetime(6)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId"); + + b.ToTable("AppUserGroupCards", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.Notification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("ExpirationTime") + .HasColumnType("datetime(6)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("NotificationId") + .HasColumnType("bigint"); + + b.Property("NotificationName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("NotificationTypeName") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("Severity") + .HasColumnType("tinyint"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "NotificationName"); + + b.ToTable("AppNotifications", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.NotificationTemplate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(1048576) + .HasColumnType("longtext"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("Culture") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Name") + .HasDatabaseName("IX_Tenant_Notification_Template_Name"); + + b.ToTable("AppNotificationTemplates", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.UserNotification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("NotificationId") + .HasColumnType("bigint"); + + b.Property("ReadStatus") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId", "NotificationId") + .HasDatabaseName("IX_Tenant_User_Notification_Id"); + + b.ToTable("AppUserNotifications", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Subscriptions.UserSubscribe", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("NotificationName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("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", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Migrations/20220624035652_Add-Entity-Notification-Template.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Migrations/20220624035652_Add-Entity-Notification-Template.cs new file mode 100644 index 000000000..4ac406c58 --- /dev/null +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Migrations/20220624035652_Add-Entity-Notification-Template.cs @@ -0,0 +1,51 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LY.MicroService.RealtimeMessage.Migrations +{ + public partial class AddEntityNotificationTemplate : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "AppNotificationTemplates", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + Name = table.Column(type: "varchar(100)", maxLength: 100, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "varchar(255)", maxLength: 255, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Title = table.Column(type: "varchar(100)", maxLength: 100, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Content = table.Column(type: "longtext", maxLength: 1048576, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Culture = table.Column(type: "varchar(30)", maxLength: 30, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true), + LastModifierId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_AppNotificationTemplates", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_Tenant_Notification_Template_Name", + table: "AppNotificationTemplates", + columns: new[] { "TenantId", "Name" }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AppNotificationTemplates"); + } + } +} diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Migrations/RealtimeMessageMigrationsDbContextModelSnapshot.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Migrations/RealtimeMessageMigrationsDbContextModelSnapshot.cs index 707c97fb2..612d4bf5e 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Migrations/RealtimeMessageMigrationsDbContextModelSnapshot.cs +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Migrations/RealtimeMessageMigrationsDbContextModelSnapshot.cs @@ -6,6 +6,8 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Volo.Abp.EntityFrameworkCore; +#nullable disable + namespace LY.MicroService.RealtimeMessage.Migrations { [DbContext(typeof(RealtimeMessageMigrationsDbContext))] @@ -16,612 +18,670 @@ namespace LY.MicroService.RealtimeMessage.Migrations #pragma warning disable 612, 618 modelBuilder .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) - .HasAnnotation("Relational:MaxIdentifierLength", 64) - .HasAnnotation("ProductVersion", "5.0.12"); + .HasAnnotation("ProductVersion", "6.0.6") + .HasAnnotation("Relational:MaxIdentifierLength", 64); modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatCard", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); - b.Property("Age") - .HasColumnType("int"); + b.Property("Age") + .HasColumnType("int"); - b.Property("AvatarUrl") - .HasMaxLength(512) - .HasColumnType("varchar(512)"); + b.Property("AvatarUrl") + .HasMaxLength(512) + .HasColumnType("varchar(512)"); - b.Property("Birthday") - .HasColumnType("datetime(6)"); + b.Property("Birthday") + .HasColumnType("datetime(6)"); - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasMaxLength(40) - .HasColumnType("varchar(40)") - .HasColumnName("ConcurrencyStamp"); + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); - b.Property("CreationTime") - .HasColumnType("datetime(6)") - .HasColumnName("CreationTime"); + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); - b.Property("CreatorId") - .HasColumnType("char(36)") - .HasColumnName("CreatorId"); + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); - b.Property("Description") - .HasMaxLength(50) - .HasColumnType("varchar(50)"); + b.Property("Description") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); - b.Property("ExtraProperties") - .HasColumnType("longtext") - .HasColumnName("ExtraProperties"); + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); - b.Property("LastModificationTime") - .HasColumnType("datetime(6)") - .HasColumnName("LastModificationTime"); + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); - b.Property("LastModifierId") - .HasColumnType("char(36)") - .HasColumnName("LastModifierId"); + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); - b.Property("LastOnlineTime") - .HasColumnType("datetime(6)"); + b.Property("LastOnlineTime") + .HasColumnType("datetime(6)"); - b.Property("NickName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); + b.Property("NickName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); - b.Property("Sex") - .HasColumnType("int"); + b.Property("Sex") + .HasColumnType("int"); - b.Property("Sign") - .HasMaxLength(30) - .HasColumnType("varchar(30)"); + b.Property("Sign") + .HasMaxLength(30) + .HasColumnType("varchar(30)"); - b.Property("State") - .HasColumnType("int"); + b.Property("State") + .HasColumnType("int"); - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); - b.Property("UserId") - .HasColumnType("char(36)"); + b.Property("UserId") + .HasColumnType("char(36)"); - b.Property("UserName") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("varchar(256)"); + b.Property("UserName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("TenantId", "UserId"); + b.HasIndex("TenantId", "UserId"); - b.ToTable("AppUserChatCards"); - }); + b.ToTable("AppUserChatCards", (string)null); + }); modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatFriend", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); - b.Property("Black") - .HasColumnType("tinyint(1)"); + b.Property("Black") + .HasColumnType("tinyint(1)"); - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasMaxLength(40) - .HasColumnType("varchar(40)") - .HasColumnName("ConcurrencyStamp"); + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); - b.Property("CreationTime") - .HasColumnType("datetime(6)") - .HasColumnName("CreationTime"); + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); - b.Property("CreatorId") - .HasColumnType("char(36)") - .HasColumnName("CreatorId"); + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); - b.Property("Description") - .HasMaxLength(50) - .HasColumnType("varchar(50)"); + b.Property("Description") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); - b.Property("DontDisturb") - .HasColumnType("tinyint(1)"); + b.Property("DontDisturb") + .HasColumnType("tinyint(1)"); - b.Property("ExtraProperties") - .HasColumnType("longtext") - .HasColumnName("ExtraProperties"); + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); - b.Property("FrientId") - .HasColumnType("char(36)"); + b.Property("FrientId") + .HasColumnType("char(36)"); - b.Property("IsStatic") - .HasColumnType("tinyint(1)"); + b.Property("IsStatic") + .HasColumnType("tinyint(1)"); - b.Property("RemarkName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); + b.Property("RemarkName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); - b.Property("SpecialFocus") - .HasColumnType("tinyint(1)"); + b.Property("SpecialFocus") + .HasColumnType("tinyint(1)"); - b.Property("Status") - .HasColumnType("tinyint unsigned"); + b.Property("Status") + .HasColumnType("tinyint unsigned"); - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); - b.Property("UserId") - .HasColumnType("char(36)"); + b.Property("UserId") + .HasColumnType("char(36)"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("TenantId", "UserId", "FrientId"); + b.HasIndex("TenantId", "UserId", "FrientId"); - b.ToTable("AppUserChatFriends"); - }); + b.ToTable("AppUserChatFriends", (string)null); + }); modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatSetting", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); - b.Property("AllowAddFriend") - .HasColumnType("tinyint(1)"); + b.Property("AllowAddFriend") + .HasColumnType("tinyint(1)"); - b.Property("AllowAnonymous") - .HasColumnType("tinyint(1)"); + b.Property("AllowAnonymous") + .HasColumnType("tinyint(1)"); - b.Property("AllowReceiveMessage") - .HasColumnType("tinyint(1)"); + b.Property("AllowReceiveMessage") + .HasColumnType("tinyint(1)"); - b.Property("AllowSendMessage") - .HasColumnType("tinyint(1)"); + b.Property("AllowSendMessage") + .HasColumnType("tinyint(1)"); - b.Property("RequireAddFriendValition") - .HasColumnType("tinyint(1)"); + b.Property("RequireAddFriendValition") + .HasColumnType("tinyint(1)"); - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); - b.Property("UserId") - .HasColumnType("char(36)"); + b.Property("UserId") + .HasColumnType("char(36)"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("TenantId", "UserId"); + b.HasIndex("TenantId", "UserId"); - b.ToTable("AppUserChatSettings"); - }); + b.ToTable("AppUserChatSettings", (string)null); + }); modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasMaxLength(40) - .HasColumnType("varchar(40)") - .HasColumnName("ConcurrencyStamp"); + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); - b.Property("Content") - .IsRequired() - .HasMaxLength(1048576) - .HasColumnType("longtext"); + b.Property("Content") + .IsRequired() + .HasMaxLength(1048576) + .HasColumnType("longtext"); - b.Property("CreationTime") - .HasColumnType("datetime(6)") - .HasColumnName("CreationTime"); + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); - b.Property("CreatorId") - .HasColumnType("char(36)") - .HasColumnName("CreatorId"); + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); - b.Property("ExtraProperties") - .HasColumnType("longtext") - .HasColumnName("ExtraProperties"); + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); - b.Property("MessageId") - .HasColumnType("bigint"); + b.Property("MessageId") + .HasColumnType("bigint"); - b.Property("ReceiveUserId") - .HasColumnType("char(36)"); + b.Property("ReceiveUserId") + .HasColumnType("char(36)"); - b.Property("SendUserName") - .IsRequired() - .HasMaxLength(64) - .HasColumnType("varchar(64)"); + b.Property("SendUserName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); - b.Property("Source") - .HasColumnType("int"); + b.Property("Source") + .HasColumnType("int"); - b.Property("State") - .HasColumnType("tinyint"); + b.Property("State") + .HasColumnType("tinyint"); - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); - b.Property("Type") - .HasColumnType("int"); + b.Property("Type") + .HasColumnType("int"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("TenantId", "ReceiveUserId"); + b.HasIndex("TenantId", "ReceiveUserId"); - b.ToTable("AppUserMessages"); - }); + b.ToTable("AppUserMessages", (string)null); + }); modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.ChatGroup", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); - b.Property("Address") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); + b.Property("Address") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); - b.Property("AdminUserId") - .HasColumnType("char(36)"); + b.Property("AdminUserId") + .HasColumnType("char(36)"); - b.Property("AllowAnonymous") - .HasColumnType("tinyint(1)"); + b.Property("AllowAnonymous") + .HasColumnType("tinyint(1)"); - b.Property("AllowSendMessage") - .HasColumnType("tinyint(1)"); + b.Property("AllowSendMessage") + .HasColumnType("tinyint(1)"); - b.Property("AvatarUrl") - .HasMaxLength(128) - .HasColumnType("varchar(128)"); + b.Property("AvatarUrl") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); - b.Property("CreationTime") - .HasColumnType("datetime(6)") - .HasColumnName("CreationTime"); + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); - b.Property("CreatorId") - .HasColumnType("char(36)") - .HasColumnName("CreatorId"); + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); - b.Property("Description") - .HasMaxLength(128) - .HasColumnType("varchar(128)"); + b.Property("Description") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); - b.Property("GroupId") - .HasColumnType("bigint"); + b.Property("GroupId") + .HasColumnType("bigint"); - b.Property("LastModificationTime") - .HasColumnType("datetime(6)") - .HasColumnName("LastModificationTime"); + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); - b.Property("LastModifierId") - .HasColumnType("char(36)") - .HasColumnName("LastModifierId"); + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); - b.Property("MaxUserCount") - .HasColumnType("int"); + b.Property("MaxUserCount") + .HasColumnType("int"); - b.Property("Name") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("varchar(20)"); + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); - b.Property("Notice") - .HasMaxLength(64) - .HasColumnType("varchar(64)"); + b.Property("Notice") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); - b.Property("Tag") - .HasMaxLength(512) - .HasColumnType("varchar(512)"); + b.Property("Tag") + .HasMaxLength(512) + .HasColumnType("varchar(512)"); - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("TenantId", "Name"); + b.HasIndex("TenantId", "Name"); - b.ToTable("AppChatGroups"); - }); + b.ToTable("AppChatGroups", (string)null); + }); modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupChatBlack", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); - b.Property("CreationTime") - .HasColumnType("datetime(6)") - .HasColumnName("CreationTime"); + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); - b.Property("CreatorId") - .HasColumnType("char(36)") - .HasColumnName("CreatorId"); + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); - b.Property("GroupId") - .HasColumnType("bigint"); + b.Property("GroupId") + .HasColumnType("bigint"); - b.Property("ShieldUserId") - .HasColumnType("char(36)"); + b.Property("ShieldUserId") + .HasColumnType("char(36)"); - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("TenantId", "GroupId"); + b.HasIndex("TenantId", "GroupId"); - b.ToTable("AppGroupChatBlacks"); - }); + b.ToTable("AppGroupChatBlacks", (string)null); + }); modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasMaxLength(40) - .HasColumnType("varchar(40)") - .HasColumnName("ConcurrencyStamp"); + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); - b.Property("Content") - .IsRequired() - .HasMaxLength(1048576) - .HasColumnType("longtext"); + b.Property("Content") + .IsRequired() + .HasMaxLength(1048576) + .HasColumnType("longtext"); - b.Property("CreationTime") - .HasColumnType("datetime(6)") - .HasColumnName("CreationTime"); + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); - b.Property("CreatorId") - .HasColumnType("char(36)") - .HasColumnName("CreatorId"); + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); - b.Property("ExtraProperties") - .HasColumnType("longtext") - .HasColumnName("ExtraProperties"); + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); - b.Property("GroupId") - .HasColumnType("bigint"); + b.Property("GroupId") + .HasColumnType("bigint"); - b.Property("MessageId") - .HasColumnType("bigint"); + b.Property("MessageId") + .HasColumnType("bigint"); - b.Property("SendUserName") - .IsRequired() - .HasMaxLength(64) - .HasColumnType("varchar(64)"); + b.Property("SendUserName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); - b.Property("Source") - .HasColumnType("int"); + b.Property("Source") + .HasColumnType("int"); - b.Property("State") - .HasColumnType("tinyint"); + b.Property("State") + .HasColumnType("tinyint"); - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); - b.Property("Type") - .HasColumnType("int"); + b.Property("Type") + .HasColumnType("int"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("TenantId", "GroupId"); + b.HasIndex("TenantId", "GroupId"); - b.ToTable("AppGroupMessages"); - }); + b.ToTable("AppGroupMessages", (string)null); + }); modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserChatGroup", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); - b.Property("CreationTime") - .HasColumnType("datetime(6)") - .HasColumnName("CreationTime"); + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); - b.Property("CreatorId") - .HasColumnType("char(36)") - .HasColumnName("CreatorId"); + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); - b.Property("GroupId") - .HasColumnType("bigint"); + b.Property("GroupId") + .HasColumnType("bigint"); - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); - b.Property("UserId") - .HasColumnType("char(36)"); + b.Property("UserId") + .HasColumnType("char(36)"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("TenantId", "GroupId", "UserId"); + b.HasIndex("TenantId", "GroupId", "UserId"); - b.ToTable("AppUserChatGroups"); - }); + b.ToTable("AppUserChatGroups", (string)null); + }); modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserGroupCard", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasMaxLength(40) - .HasColumnType("varchar(40)") - .HasColumnName("ConcurrencyStamp"); + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); - b.Property("CreationTime") - .HasColumnType("datetime(6)") - .HasColumnName("CreationTime"); + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); - b.Property("CreatorId") - .HasColumnType("char(36)") - .HasColumnName("CreatorId"); + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); - b.Property("ExtraProperties") - .HasColumnType("longtext") - .HasColumnName("ExtraProperties"); + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); - b.Property("IsAdmin") - .HasColumnType("tinyint(1)"); + b.Property("IsAdmin") + .HasColumnType("tinyint(1)"); - b.Property("LastModificationTime") - .HasColumnType("datetime(6)") - .HasColumnName("LastModificationTime"); + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); - b.Property("LastModifierId") - .HasColumnType("char(36)") - .HasColumnName("LastModifierId"); + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); - b.Property("NickName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); + b.Property("NickName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); - b.Property("SilenceEnd") - .HasColumnType("datetime(6)"); + b.Property("SilenceEnd") + .HasColumnType("datetime(6)"); - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); - b.Property("UserId") - .HasColumnType("char(36)"); + b.Property("UserId") + .HasColumnType("char(36)"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("TenantId", "UserId"); + b.HasIndex("TenantId", "UserId"); - b.ToTable("AppUserGroupCards"); - }); + b.ToTable("AppUserGroupCards", (string)null); + }); modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.Notification", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("ExpirationTime") + .HasColumnType("datetime(6)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("NotificationId") + .HasColumnType("bigint"); + + b.Property("NotificationName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("NotificationTypeName") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("Severity") + .HasColumnType("tinyint"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "NotificationName"); + + b.ToTable("AppNotifications", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.NotificationTemplate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(1048576) + .HasColumnType("longtext"); - b.Property("CreationTime") - .HasColumnType("datetime(6)") - .HasColumnName("CreationTime"); + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); - b.Property("ExpirationTime") - .HasColumnType("datetime(6)"); + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); - b.Property("ExtraProperties") - .HasColumnType("longtext") - .HasColumnName("ExtraProperties"); + b.Property("Culture") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)"); - b.Property("NotificationId") - .HasColumnType("bigint"); + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); - b.Property("NotificationName") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("varchar(100)"); + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); - b.Property("NotificationTypeName") - .IsRequired() - .HasMaxLength(512) - .HasColumnType("varchar(512)"); + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); - b.Property("Severity") - .HasColumnType("tinyint"); + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); - b.Property("Type") - .HasColumnType("int"); + b.Property("Title") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("TenantId", "NotificationName"); + b.HasIndex("TenantId", "Name") + .HasDatabaseName("IX_Tenant_Notification_Template_Name"); - b.ToTable("AppNotifications"); - }); + b.ToTable("AppNotificationTemplates", (string)null); + }); modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.UserNotification", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); - b.Property("NotificationId") - .HasColumnType("bigint"); + b.Property("NotificationId") + .HasColumnType("bigint"); - b.Property("ReadStatus") - .HasColumnType("int"); + b.Property("ReadStatus") + .HasColumnType("int"); - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); - b.Property("UserId") - .HasColumnType("char(36)"); + b.Property("UserId") + .HasColumnType("char(36)"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("TenantId", "UserId", "NotificationId") - .HasDatabaseName("IX_Tenant_User_Notification_Id"); + b.HasIndex("TenantId", "UserId", "NotificationId") + .HasDatabaseName("IX_Tenant_User_Notification_Id"); - b.ToTable("AppUserNotifications"); - }); + b.ToTable("AppUserNotifications", (string)null); + }); modelBuilder.Entity("LINGYUN.Abp.MessageService.Subscriptions.UserSubscribe", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - b.Property("CreationTime") - .HasColumnType("datetime(6)") - .HasColumnName("CreationTime"); - - b.Property("NotificationName") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("TenantId") - .HasColumnType("char(36)") - .HasColumnName("TenantId"); - - b.Property("UserId") - .HasColumnType("char(36)"); - - b.Property("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"); - }); + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("NotificationName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("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", (string)null); + }); #pragma warning restore 612, 618 } } diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs index 1ed2a4c22..ecf044a5b 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs @@ -17,6 +17,7 @@ using LINGYUN.Abp.MessageService.EntityFrameworkCore; using LINGYUN.Abp.Notifications.Emailing; using LINGYUN.Abp.Notifications.SignalR; using LINGYUN.Abp.Notifications.Sms; +using LINGYUN.Abp.Notifications.TextTemplating; using LINGYUN.Abp.Notifications.WeChat.MiniProgram; using LINGYUN.Abp.Saas.EntityFrameworkCore; using LINGYUN.Abp.Serilog.Enrichers.Application; @@ -36,6 +37,7 @@ using Volo.Abp.Caching.StackExchangeRedis; using Volo.Abp.Modularity; using Volo.Abp.PermissionManagement.EntityFrameworkCore; using Volo.Abp.SettingManagement.EntityFrameworkCore; +using Volo.Abp.TextTemplating.Scriban; namespace LY.MicroService.RealtimeMessage; @@ -67,6 +69,8 @@ namespace LY.MicroService.RealtimeMessage; typeof(AbpNotificationsSignalRModule), typeof(AbpNotificationsWeChatMiniProgramModule), typeof(AbpNotificationsExceptionHandlingModule), + typeof(AbpNotificationsTextTemplatingModule), + typeof(AbpTextTemplatingScribanModule), typeof(AbpCAPEventBusModule), typeof(AbpCachingStackExchangeRedisModule), typeof(AbpAspNetCoreHttpOverridesModule), @@ -105,6 +109,8 @@ public partial class RealtimeMessageHttpApiHostModule : AbpModule ConfigureCors(context.Services, configuration); ConfigureSeedWorker(context.Services, hostingEnvironment.IsDevelopment()); ConfigureSecurity(context.Services, configuration, hostingEnvironment.IsDevelopment()); + + context.Services.AddAlwaysAllowAuthorization(); } public override void OnApplicationInitialization(ApplicationInitializationContext context) diff --git a/aspnet-core/services/LY.MicroService.identityServer/Emailing/Templates/MailSecurityVerify.tpl b/aspnet-core/services/LY.MicroService.identityServer/Emailing/Templates/MailSecurityVerify.tpl index b3a9f4df7..60a3bbf0a 100644 --- a/aspnet-core/services/LY.MicroService.identityServer/Emailing/Templates/MailSecurityVerify.tpl +++ b/aspnet-core/services/LY.MicroService.identityServer/Emailing/Templates/MailSecurityVerify.tpl @@ -1,5 +1,5 @@ 
- {{L "VerifyMyEmailAddress" model.user}} + {{L "VerifyMyEmailAddress"}}{{model.user}}

{{model.code}}

{{L "MailSecurityVerifyRemarks"}}
\ No newline at end of file
-
{{ header }} +
{{ model.header }}
    -
  • 异常类型 : {{ title }}
  • -
  • 异常信息 : {{ message }}
  • -
  • 告警级别 : {{ loglevel }}
  • -
  • 触发时间 : {{ createTime }}
  • +
  • 异常类型 : {{ model.title }}
  • +
  • 异常信息 : {{ model.message }}
  • +
  • 告警级别 : {{ model.loglevel }}
  • + +
  • 触发时间 : {{ creationTime }}
-
{{ stacktrace }}
+
{{ model.stackTrace }}


- {{ footer }} + {{ model.footer }}