diff --git a/aspnet-core/LINGYUN.MicroService.All.sln b/aspnet-core/LINGYUN.MicroService.All.sln index e4a9ea883..6738df512 100644 --- a/aspnet-core/LINGYUN.MicroService.All.sln +++ b/aspnet-core/LINGYUN.MicroService.All.sln @@ -408,7 +408,23 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Platform.Theme.VueV EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Platform.Settings.VueVbenAdmin", "modules\platform\LINGYUN.Platform.Settings.VueVbenAdmin\LINGYUN.Platform.Settings.VueVbenAdmin.csproj", "{8DF55DAB-4C1D-46F7-9324-0050F47B3BED}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Notifications.TextTemplating", "modules\common\LINGYUN.Abp.Notifications.TextTemplating\LINGYUN.Abp.Notifications.TextTemplating.csproj", "{06FF5EFA-DEDA-4E12-A482-8FCE4077F68A}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "text-templating", "text-templating", "{ABD89F39-62D9-439E-8662-BE4F36BFA04F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.TextTemplating.Domain.Shared", "modules\text-templating\LINGYUN.Abp.TextTemplating.Domain.Shared\LINGYUN.Abp.TextTemplating.Domain.Shared.csproj", "{D4B4800F-6238-4EA9-A9BB-298D668C26C4}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.TextTemplating.Domain", "modules\text-templating\LINGYUN.Abp.TextTemplating.Domain\LINGYUN.Abp.TextTemplating.Domain.csproj", "{F9AC4123-7987-47D3-85D6-CD13928F3683}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.TextTemplating.Application.Contracts", "modules\text-templating\LINGYUN.Abp.TextTemplating.Application.Contracts\LINGYUN.Abp.TextTemplating.Application.Contracts.csproj", "{22BDDF5C-F911-4978-B83F-981F3652BF45}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.TextTemplating.Application", "modules\text-templating\LINGYUN.Abp.TextTemplating.Application\LINGYUN.Abp.TextTemplating.Application.csproj", "{0C824BB4-81FC-4B28-B7B1-07B2B2BB70A0}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.TextTemplating.HttpApi", "modules\text-templating\LINGYUN.Abp.TextTemplating.HttpApi\LINGYUN.Abp.TextTemplating.HttpApi.csproj", "{4711320B-F98D-4CB0-BFEB-B9685B6CBCB7}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.TextTemplating.EntityFrameworkCore", "modules\text-templating\LINGYUN.Abp.TextTemplating.EntityFrameworkCore\LINGYUN.Abp.TextTemplating.EntityFrameworkCore.csproj", "{130F8ED1-A64F-48DE-BF43-18EAD19CAF63}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.TextTemplating.HttpApi.Client", "modules\text-templating\LINGYUN.Abp.TextTemplating.HttpApi.Client\LINGYUN.Abp.TextTemplating.HttpApi.Client.csproj", "{A53FE09E-6B1C-46C0-9422-C313D14AE9E4}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Notifications.Common", "modules\common\LINGYUN.Abp.Notifications.Common\LINGYUN.Abp.Notifications.Common.csproj", "{0CE035CF-2D8A-4559-93EC-ADBEC4237C61}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -1056,10 +1072,38 @@ Global {8DF55DAB-4C1D-46F7-9324-0050F47B3BED}.Debug|Any CPU.Build.0 = Debug|Any CPU {8DF55DAB-4C1D-46F7-9324-0050F47B3BED}.Release|Any CPU.ActiveCfg = Release|Any CPU {8DF55DAB-4C1D-46F7-9324-0050F47B3BED}.Release|Any CPU.Build.0 = Release|Any CPU - {06FF5EFA-DEDA-4E12-A482-8FCE4077F68A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {06FF5EFA-DEDA-4E12-A482-8FCE4077F68A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {06FF5EFA-DEDA-4E12-A482-8FCE4077F68A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {06FF5EFA-DEDA-4E12-A482-8FCE4077F68A}.Release|Any CPU.Build.0 = Release|Any CPU + {D4B4800F-6238-4EA9-A9BB-298D668C26C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D4B4800F-6238-4EA9-A9BB-298D668C26C4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D4B4800F-6238-4EA9-A9BB-298D668C26C4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D4B4800F-6238-4EA9-A9BB-298D668C26C4}.Release|Any CPU.Build.0 = Release|Any CPU + {F9AC4123-7987-47D3-85D6-CD13928F3683}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F9AC4123-7987-47D3-85D6-CD13928F3683}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F9AC4123-7987-47D3-85D6-CD13928F3683}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F9AC4123-7987-47D3-85D6-CD13928F3683}.Release|Any CPU.Build.0 = Release|Any CPU + {22BDDF5C-F911-4978-B83F-981F3652BF45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {22BDDF5C-F911-4978-B83F-981F3652BF45}.Debug|Any CPU.Build.0 = Debug|Any CPU + {22BDDF5C-F911-4978-B83F-981F3652BF45}.Release|Any CPU.ActiveCfg = Release|Any CPU + {22BDDF5C-F911-4978-B83F-981F3652BF45}.Release|Any CPU.Build.0 = Release|Any CPU + {0C824BB4-81FC-4B28-B7B1-07B2B2BB70A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0C824BB4-81FC-4B28-B7B1-07B2B2BB70A0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0C824BB4-81FC-4B28-B7B1-07B2B2BB70A0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0C824BB4-81FC-4B28-B7B1-07B2B2BB70A0}.Release|Any CPU.Build.0 = Release|Any CPU + {4711320B-F98D-4CB0-BFEB-B9685B6CBCB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4711320B-F98D-4CB0-BFEB-B9685B6CBCB7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4711320B-F98D-4CB0-BFEB-B9685B6CBCB7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4711320B-F98D-4CB0-BFEB-B9685B6CBCB7}.Release|Any CPU.Build.0 = Release|Any CPU + {130F8ED1-A64F-48DE-BF43-18EAD19CAF63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {130F8ED1-A64F-48DE-BF43-18EAD19CAF63}.Debug|Any CPU.Build.0 = Debug|Any CPU + {130F8ED1-A64F-48DE-BF43-18EAD19CAF63}.Release|Any CPU.ActiveCfg = Release|Any CPU + {130F8ED1-A64F-48DE-BF43-18EAD19CAF63}.Release|Any CPU.Build.0 = Release|Any CPU + {A53FE09E-6B1C-46C0-9422-C313D14AE9E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A53FE09E-6B1C-46C0-9422-C313D14AE9E4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A53FE09E-6B1C-46C0-9422-C313D14AE9E4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A53FE09E-6B1C-46C0-9422-C313D14AE9E4}.Release|Any CPU.Build.0 = Release|Any CPU + {0CE035CF-2D8A-4559-93EC-ADBEC4237C61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0CE035CF-2D8A-4559-93EC-ADBEC4237C61}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0CE035CF-2D8A-4559-93EC-ADBEC4237C61}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0CE035CF-2D8A-4559-93EC-ADBEC4237C61}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1259,7 +1303,15 @@ Global {88502844-D83C-4541-96AC-A8291E261F63} = {8AC72641-30D3-4ACF-89FA-808FADC55C2E} {67DC7FA0-506A-4977-95F6-BC739B2BC4BA} = {F4923692-D343-4318-AECA-96F580B1A563} {8DF55DAB-4C1D-46F7-9324-0050F47B3BED} = {F4923692-D343-4318-AECA-96F580B1A563} - {06FF5EFA-DEDA-4E12-A482-8FCE4077F68A} = {8AC72641-30D3-4ACF-89FA-808FADC55C2E} + {ABD89F39-62D9-439E-8662-BE4F36BFA04F} = {C5CAD011-DF84-4914-939C-0C029DCEF26F} + {D4B4800F-6238-4EA9-A9BB-298D668C26C4} = {ABD89F39-62D9-439E-8662-BE4F36BFA04F} + {F9AC4123-7987-47D3-85D6-CD13928F3683} = {ABD89F39-62D9-439E-8662-BE4F36BFA04F} + {22BDDF5C-F911-4978-B83F-981F3652BF45} = {ABD89F39-62D9-439E-8662-BE4F36BFA04F} + {0C824BB4-81FC-4B28-B7B1-07B2B2BB70A0} = {ABD89F39-62D9-439E-8662-BE4F36BFA04F} + {4711320B-F98D-4CB0-BFEB-B9685B6CBCB7} = {ABD89F39-62D9-439E-8662-BE4F36BFA04F} + {130F8ED1-A64F-48DE-BF43-18EAD19CAF63} = {ABD89F39-62D9-439E-8662-BE4F36BFA04F} + {A53FE09E-6B1C-46C0-9422-C313D14AE9E4} = {ABD89F39-62D9-439E-8662-BE4F36BFA04F} + {0CE035CF-2D8A-4559-93EC-ADBEC4237C61} = {8AC72641-30D3-4ACF-89FA-808FADC55C2E} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C95FDF91-16F2-4A8B-A4BE-0E62D1B66718} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN.Abp.ExceptionHandling.Notifications.csproj b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN.Abp.ExceptionHandling.Notifications.csproj index 9b0725319..3b6c49a28 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN.Abp.ExceptionHandling.Notifications.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN.Abp.ExceptionHandling.Notifications.csproj @@ -8,16 +8,6 @@ - - - - - - - - - - @@ -25,7 +15,7 @@ - + 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 deleted file mode 100644 index effab95a1..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN/Abp/ExceptionHandling/Notifications/AbpExceptionHandlingNotificationDefinitionProvider.cs +++ /dev/null @@ -1,37 +0,0 @@ -using LINGYUN.Abp.ExceptionHandling.Localization; -using LINGYUN.Abp.Notifications; -using Volo.Abp.Localization; - -namespace LINGYUN.Abp.ExceptionHandling.Notifications -{ - public class AbpExceptionHandlingNotificationDefinitionProvider : NotificationDefinitionProvider - { - public override void Define(INotificationDefinitionContext context) - { - var exceptionGroup = context.AddGroup( - AbpExceptionHandlingNotificationNames.GroupName, - L("Notifications:Exception"), - false); - - exceptionGroup.AddNotification( - name: AbpExceptionHandlingNotificationNames.NotificationName, - displayName: L("Notifications:ExceptionNotifier"), - description: L("Notifications:ExceptionNotifier"), - notificationType: NotificationType.System, - lifetime: NotificationLifetime.Persistent, - allowSubscriptionToClients: false) - // 指定通知提供程序 - .WithProviders( - NotificationProviderNames.SignalR, - NotificationProviderNames.Emailing) - // 特定的通知提供程序属性 - // 此处为邮件通知定义的模板名称 - .WithProperty("Template", "ExceptionNotifier"); - } - - protected LocalizableString L(string name) - { - return LocalizableString.Create(name); - } - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN/Abp/ExceptionHandling/Notifications/AbpExceptionHandlingNotificationNames.cs b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN/Abp/ExceptionHandling/Notifications/AbpExceptionHandlingNotificationNames.cs deleted file mode 100644 index 9c8b2caa2..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN/Abp/ExceptionHandling/Notifications/AbpExceptionHandlingNotificationNames.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace LINGYUN.Abp.ExceptionHandling.Notifications -{ - public class AbpExceptionHandlingNotificationNames - { - public const string GroupName = "LINGYUN.Abp.ExceptionHandling"; - public const string NotificationName = GroupName + ".Notifier"; - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN/Abp/ExceptionHandling/Notifications/AbpNotificationsExceptionHandlingModule.cs b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN/Abp/ExceptionHandling/Notifications/AbpNotificationsExceptionHandlingModule.cs index 1f9d501f9..2ee8d8294 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN/Abp/ExceptionHandling/Notifications/AbpNotificationsExceptionHandlingModule.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN/Abp/ExceptionHandling/Notifications/AbpNotificationsExceptionHandlingModule.cs @@ -1,29 +1,12 @@ -using LINGYUN.Abp.ExceptionHandling.Localization; -using LINGYUN.Abp.Notifications; -using Volo.Abp.Localization; +using LINGYUN.Abp.Notifications.Common; using Volo.Abp.Modularity; -using Volo.Abp.VirtualFileSystem; namespace LINGYUN.Abp.ExceptionHandling.Notifications { [DependsOn( typeof(AbpExceptionHandlingModule), - typeof(AbpNotificationModule))] + typeof(AbpNotificationsCommonModule))] public class AbpNotificationsExceptionHandlingModule : AbpModule { - public override void ConfigureServices(ServiceConfigurationContext context) - { - Configure(options => - { - options.FileSets.AddEmbedded(); - }); - - Configure(options => - { - options.Resources - .Get() - .AddVirtualJson("/LINGYUN/Abp/ExceptionHandling/Notifications/Localization/Resources"); - }); - } } } 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..0507d8211 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, + NotificationsCommonNotificationNames.ExceptionHandling, + new NotificationTemplate( + NotificationsCommonNotificationNames.ExceptionHandling, + 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.ExceptionHandling.Notifications/LINGYUN/Abp/ExceptionHandling/Notifications/Localization/Resources/en.json b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN/Abp/ExceptionHandling/Notifications/Localization/Resources/en.json deleted file mode 100644 index 16edd1673..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN/Abp/ExceptionHandling/Notifications/Localization/Resources/en.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "culture": "en", - "texts": { - "Notifications:Exception": "Exception", - "Notifications:ExceptionNotifier": "Exception Notifier" - } -} \ No newline at end of file diff --git a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN/Abp/ExceptionHandling/Notifications/Localization/Resources/zh-Hans.json b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN/Abp/ExceptionHandling/Notifications/Localization/Resources/zh-Hans.json deleted file mode 100644 index 9649f9c04..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN/Abp/ExceptionHandling/Notifications/Localization/Resources/zh-Hans.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "culture": "zh-Hans", - "texts": { - "Notifications:Exception": "异常通知", - "Notifications:ExceptionNotifier": "异常推送" - } -} \ No newline at end of file diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.TextTemplating/FodyWeavers.xml b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/FodyWeavers.xml similarity index 100% rename from aspnet-core/modules/common/LINGYUN.Abp.Notifications.TextTemplating/FodyWeavers.xml rename to aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/FodyWeavers.xml diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/FodyWeavers.xsd b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/FodyWeavers.xsd new file mode 100644 index 000000000..11da52550 --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/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.Common/LINGYUN.Abp.Notifications.Common.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/LINGYUN.Abp.Notifications.Common.csproj new file mode 100644 index 000000000..a1cf305d7 --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/LINGYUN.Abp.Notifications.Common.csproj @@ -0,0 +1,31 @@ + + + + + + + netstandard2.0 + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/LINGYUN/Abp/Notifications/AbpNotificationsCommonModule.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/LINGYUN/Abp/Notifications/AbpNotificationsCommonModule.cs new file mode 100644 index 000000000..19b1664bd --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/LINGYUN/Abp/Notifications/AbpNotificationsCommonModule.cs @@ -0,0 +1,26 @@ +using LINGYUN.Abp.Notifications.Localization; +using Volo.Abp.Localization; +using Volo.Abp.Modularity; +using Volo.Abp.VirtualFileSystem; + +namespace LINGYUN.Abp.Notifications.Common; + +[DependsOn( + typeof(AbpNotificationModule))] +public class AbpNotificationsCommonModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.FileSets.AddEmbedded(); + }); + + Configure(options => + { + options.Resources + .Get() + .AddVirtualJson("/LINGYUN/Abp/Notifications/Localization/Common"); + }); + } +} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/LINGYUN/Abp/Notifications/Emailing/NotificationsCommonTemplateProvider.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/LINGYUN/Abp/Notifications/Emailing/NotificationsCommonTemplateProvider.cs new file mode 100644 index 000000000..2678d777a --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/LINGYUN/Abp/Notifications/Emailing/NotificationsCommonTemplateProvider.cs @@ -0,0 +1,23 @@ +using Volo.Abp.TextTemplating; + +namespace LINGYUN.Abp.Notifications; + +public class NotificationsCommonTemplateProvider : TemplateDefinitionProvider +{ + public override void Define(ITemplateDefinitionContext context) + { + context.Add(CreateEmailTemplate()); + } + + protected virtual TemplateDefinition[] CreateEmailTemplate() + { + return new TemplateDefinition[] + { + new TemplateDefinition( + name: "EmailNotifierLayout", + defaultCultureName: "en", + isLayout: true) + .WithVirtualFilePath( "/LINGYUN/Abp/Notifications/Emailing/Templates/layout.tpl", isInlineLocalized: true) + }; + } +} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/LINGYUN/Abp/Notifications/Localization/Common/en.json b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/LINGYUN/Abp/Notifications/Localization/Common/en.json new file mode 100644 index 000000000..b12c0c053 --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/LINGYUN/Abp/Notifications/Localization/Common/en.json @@ -0,0 +1,11 @@ +{ + "culture": "en", + "texts": { + "Notifications:MultiTenancy": "Multi Tenancy", + "Notifications:Users": "Users", + "Notifications:NewTenantRegisterd": "Tenant creation notification", + "Notifications:WelcomeToApplication": "User Welcome Notice", + "Notifications:Primitives": "Primitives", + "Notifications:ExceptionNotifier": "Exception Notifier" + } +} \ No newline at end of file diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/LINGYUN/Abp/Notifications/Localization/Common/zh-Hans.json b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/LINGYUN/Abp/Notifications/Localization/Common/zh-Hans.json new file mode 100644 index 000000000..bde90e888 --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/LINGYUN/Abp/Notifications/Localization/Common/zh-Hans.json @@ -0,0 +1,11 @@ +{ + "culture": "zh-Hans", + "texts": { + "Notifications:MultiTenancy": "租户通知", + "Notifications:Users": "用户通知", + "Notifications:NewTenantRegisterd": "租户创建通知", + "Notifications:WelcomeToApplication": "用户欢迎通知", + "Notifications:Primitives": "标准通知", + "Notifications:ExceptionNotifier": "异常通知推送" + } +} \ No newline at end of file diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/LINGYUN/Abp/Notifications/NotificationsCommonNotificationDefinitionProvider.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/LINGYUN/Abp/Notifications/NotificationsCommonNotificationDefinitionProvider.cs new file mode 100644 index 000000000..fd60c0863 --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/LINGYUN/Abp/Notifications/NotificationsCommonNotificationDefinitionProvider.cs @@ -0,0 +1,82 @@ +using LINGYUN.Abp.Notifications.Localization; +using Volo.Abp.Localization; +using Volo.Abp.MultiTenancy; +using Volo.Abp.TextTemplating; +using Volo.Abp.Users; + +namespace LINGYUN.Abp.Notifications; +public class NotificationsCommonNotificationDefinitionProvider : NotificationDefinitionProvider +{ + public override void Define(INotificationDefinitionContext context) + { + var commonGroup = context.AddGroup( + NotificationsCommonNotificationNames.GroupName, + L("Notifications:Primitives"), + false); + + commonGroup.AddNotification( + name: NotificationsCommonNotificationNames.ExceptionHandling, + displayName: L("Notifications:ExceptionNotifier"), + description: L("Notifications:ExceptionNotifier"), + notificationType: NotificationType.System, + lifetime: NotificationLifetime.Persistent, + allowSubscriptionToClients: false) + // 指定通知提供程序 + .WithProviders( + NotificationProviderNames.SignalR, + NotificationProviderNames.Emailing) + // 设定为模板通知 + .WithTemplate(typeof(NotificationsResource), layout: "EmailNotifierLayout") + .WithTemplate(template => + { + template.WithVirtualFilePath("/LINGYUN/Abp/Notifications/Emailing/Templates/ExceptionNotifier", isInlineLocalized: false); + }); + + var tenantsGroup = context.AddGroup( + TenantNotificationNames.GroupName, + L("Notifications:MultiTenancy"), + false); + + tenantsGroup.AddNotification( + TenantNotificationNames.NewTenantRegistered, + L("Notifications:NewTenantRegisterd"), + L("Notifications:NewTenantRegisterd"), + notificationType: NotificationType.System, + lifetime: NotificationLifetime.OnlyOne, + allowSubscriptionToClients: false + ) + .WithProviders( + NotificationProviderNames.SignalR, + NotificationProviderNames.Emailing) + .WithTemplate(typeof(NotificationsResource), layout: "EmailNotifierLayout") + .WithTemplate(template => + { + template.WithVirtualFilePath("/LINGYUN/Abp/Notifications/Emailing/Templates/NewTenantRegisterd", isInlineLocalized: false); + }); + + var usersGroup = context.AddGroup( + UserNotificationNames.GroupName, + L("Notifications:Users")); + + usersGroup.AddNotification( + UserNotificationNames.WelcomeToApplication, + L("Notifications:WelcomeToApplication"), + L("Notifications:WelcomeToApplication"), + notificationType: NotificationType.System, + lifetime: NotificationLifetime.OnlyOne, + allowSubscriptionToClients: true) + .WithProviders( + NotificationProviderNames.SignalR, + NotificationProviderNames.Emailing) + .WithTemplate(typeof(NotificationsResource), layout: "EmailNotifierLayout") + .WithTemplate(template => + { + template.WithVirtualFilePath("/LINGYUN/Abp/Notifications/Emailing/Templates/WelcomeToApplication", isInlineLocalized: false); + }); + } + + protected LocalizableString L(string name) + { + return LocalizableString.Create(name); + } +} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/LINGYUN/Abp/Notifications/NotificationsCommonNotificationNames.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/LINGYUN/Abp/Notifications/NotificationsCommonNotificationNames.cs new file mode 100644 index 000000000..071c35ed4 --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/LINGYUN/Abp/Notifications/NotificationsCommonNotificationNames.cs @@ -0,0 +1,11 @@ +namespace LINGYUN.Abp.Notifications +{ + public class NotificationsCommonNotificationNames + { + public const string GroupName = "LINGYUN.Abp.Notifications.Primitives"; + /// + /// 异常处理 + /// + public const string ExceptionHandling = GroupName + ".ExceptionHandling"; + } +} diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/Volo/Abp/MultiTenancy/TenantNotificationNames.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/Volo/Abp/MultiTenancy/TenantNotificationNames.cs similarity index 100% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/Volo/Abp/MultiTenancy/TenantNotificationNames.cs rename to aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/Volo/Abp/MultiTenancy/TenantNotificationNames.cs diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/Volo/Abp/Users/UserNotificationNames.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/Volo/Abp/Users/UserNotificationNames.cs similarity index 100% rename from aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/Volo/Abp/Users/UserNotificationNames.cs rename to aspnet-core/modules/common/LINGYUN.Abp.Notifications.Common/Volo/Abp/Users/UserNotificationNames.cs 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/LINGYUN/Abp/Notifications/TextTemplating/AbpNotificationsTextTemplatingModule.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.TextTemplating/LINGYUN/Abp/Notifications/TextTemplating/AbpNotificationsTextTemplatingModule.cs deleted file mode 100644 index 3cfb08970..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.TextTemplating/LINGYUN/Abp/Notifications/TextTemplating/AbpNotificationsTextTemplatingModule.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Volo.Abp.Modularity; -using Volo.Abp.TextTemplating; - -namespace LINGYUN.Abp.Notifications.TextTemplating; - -[DependsOn( - typeof(AbpNotificationModule), - typeof(AbpTextTemplatingCoreModule))] -public class AbpNotificationsTextTemplatingModule : AbpModule -{ - -} 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 deleted file mode 100644 index f1708d705..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.TextTemplating/LINGYUN/Abp/Notifications/TextTemplating/NotificationTemplateContentContributor.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using System.Threading.Tasks; -using Volo.Abp.DependencyInjection; -using Volo.Abp.TextTemplating; - -namespace LINGYUN.Abp.Notifications.TextTemplating; - -public class NotificationTemplateContentContributor : ITemplateContentContributor, ITransientDependency -{ - public async virtual Task GetOrNullAsync(TemplateContentContributorContext context) - { - var store = context.ServiceProvider.GetRequiredService(); - - return await store.GetOrNullAsync(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 deleted file mode 100644 index f2a39812e..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/INotificationTemplateStore.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; - -namespace LINGYUN.Abp.Notifications; - -public interface INotificationTemplateStore -{ - Task GetOrNullAsync(string templateName, string culture = null, CancellationToken cancellationToken = default); -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/Localization/Resources/en.json b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/Localization/Resources/en.json index 974a19e4f..a45236c6c 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/Localization/Resources/en.json +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/Localization/Resources/en.json @@ -1,12 +1,24 @@ { "culture": "en", "texts": { + "Notifications": "Notifications", + "Notifications:Title": "Title", + "Notifications:Content": "Content", + "Notifications:Type": "Type", + "Notifications:SendTime": "SendTime", + "Notifications:System": "System", + "Notifications:Application": "Platform", + "Notifications:User": "User", "Notifications:Internal": "Internal", "Notifications:OnsideNotice": "Onside", "Notifications:OnsideNoticeDesc": "In-app notification push", "Notifications:ActivityNotice": "Activity", "Notifications:ActivityNoticeDesc": "The administrator delivers an event notification push", "Notifications:SystemNotice": "System", - "Notifications:SystemNoticeDesc": "System global notification push" + "Notifications:SystemNoticeDesc": "System global notification push", + "MarkSelectedAsRead": "Mark selected as read", + "MarkAs": "Mark as", + "Read": "Read", + "UnRead": "Un Read" } } \ No newline at end of file diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/Localization/Resources/zh-Hans.json b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/Localization/Resources/zh-Hans.json index c5ea0dec4..65fdcd866 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/Localization/Resources/zh-Hans.json +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/Localization/Resources/zh-Hans.json @@ -1,12 +1,24 @@ { "culture": "zh-Hans", "texts": { + "Notifications": "通知列表", + "Notifications:Title": "标题", + "Notifications:Content": "内容", + "Notifications:Type": "类型", + "Notifications:SendTime": "发送时间", + "Notifications:System": "系统", + "Notifications:Application": "平台", + "Notifications:User": "用户", "Notifications:Internal": "内置通知", "Notifications:OnsideNotice": "站内通知", "Notifications:OnsideNoticeDesc": "应用内部通知推送", "Notifications:ActivityNotice": "活动通知", "Notifications:ActivityNoticeDesc": "管理员下发活动通知推送", "Notifications:SystemNotice": "系统通知", - "Notifications:SystemNoticeDesc": "系统全局消息推送" + "Notifications:SystemNoticeDesc": "系统全局消息推送", + "MarkSelectedAsRead": "标记选中已读", + "MarkAs": "标记为", + "Read": "已读", + "UnRead": "未读" } } \ No newline at end of file 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..199e4b9c7 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,40 @@ 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 WithTemplate(Action setup) + { + if (Template != null) + { + setup(Template); + } + else + { + var template = new TemplateDefinition(Name); + setup(template); + + Template = template; + } + + 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 deleted file mode 100644 index f5b4da58c..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NullNotificationTemplateStore.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; -using Volo.Abp.DependencyInjection; - -namespace LINGYUN.Abp.Notifications; - -[Dependency(TryRegister = true)] -public class NullNotificationTemplateStore : INotificationTemplateStore, ISingletonDependency -{ - public readonly static INotificationTemplateStore Instance = new NullNotificationTemplateStore(); - - public Task GetOrNullAsync(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/INotificationAppService.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/INotificationAppService.cs index 3af9843d1..0782b12e3 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,12 @@ using System.Threading.Tasks; - +using Volo.Abp.Application.Dtos; + namespace LINGYUN.Abp.MessageService.Notifications { public interface INotificationAppService { + Task> GetAssignableTemplatesAsync(); + Task SendAsync(NotificationSendDto input); } } 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..9ca440640 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,88 @@ 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; } public NotificationAppService( - INotificationSender notificationSender) + INotificationSender notificationSender, + ITemplateContentProvider templateContentProvider, + INotificationDefinitionManager notificationDefinitionManager) { NotificationSender = notificationSender; + TemplateContentProvider = templateContentProvider; + NotificationDefinitionManager = notificationDefinitionManager; + } + + 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 virtual async Task SendAsync(NotificationSendDto input) + 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 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..bd71bebcb 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,22 +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!", - "MarkSelectedAsRead": "Mark selected as read", - "MarkAs": "Mark as", - "Read": "Read", - "UnRead": "Un Read", - "Notifications": "Notifications", - "Notifications:Title": "Title", - "Notifications:Content": "Content", - "Notifications:Type": "Type", - "Notifications:SendTime": "SendTime", - "Notifications:System": "System", - "Notifications:Application": "Platform", - "Notifications:User": "User", - "Notifications:MultiTenancy": "Multi Tenancy", - "Notifications:Users": "Users", - "Notifications:NewTenantRegisterd": "Tenant creation notification", - "Notifications:WelcomeToApplication": "User Welcome Notice", + "LINGYUN.Abp.Message:05404": "The notification template does not exist!", "Notifications:IM": "Instant Messaging", "Notifications:FriendValidation": "Friend verification notification", "Notifications:NewFriend": "New friend notification", 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..069f1bc65 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,22 +18,7 @@ "LINGYUN.Abp.Message:03404": "发送消息失败: 用户不存在或已注销账号!", "LINGYUN.Abp.Message:03410": "用户拒绝添加好友", "LINGYUN.Abp.Message:03411": "对方已是您的好友或已发送验证请求,不能重复操作!", - "MarkSelectedAsRead": "标记选中已读", - "MarkAs": "标记为", - "Read": "已读", - "UnRead": "未读", - "Notifications": "通知列表", - "Notifications:Title": "标题", - "Notifications:Content": "内容", - "Notifications:Type": "类型", - "Notifications:SendTime": "发送时间", - "Notifications:System": "系统", - "Notifications:Application": "平台", - "Notifications:User": "用户", - "Notifications:MultiTenancy": "租户通知", - "Notifications:Users": "用户通知", - "Notifications:NewTenantRegisterd": "租户创建通知", - "Notifications:WelcomeToApplication": "用户欢迎通知", + "LINGYUN.Abp.Message:05404": "通知模板不存在!", "Notifications:IM": "即时通讯", "Notifications:FriendValidation": "好友验证通知", "Notifications:NewFriend": "新好友通知", @@ -45,6 +30,5 @@ "AddNewFriendBySearchId": "通过账号搜索添加", "WelcomeToApplicationFormUser": "用户:{User} 欢迎您的加入!", "Messages:NewFriend": "我已经添加您为好友,让我们一起聊天吧!" - } } \ No newline at end of file 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..04a92ea9b 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 @@ -1,8 +1,6 @@ using LINGYUN.Abp.MessageService.Localization; using LINGYUN.Abp.Notifications; using Volo.Abp.Localization; -using Volo.Abp.MultiTenancy; -using Volo.Abp.Users; namespace LINGYUN.Abp.MessageService.Notifications { @@ -10,40 +8,6 @@ namespace LINGYUN.Abp.MessageService.Notifications { public override void Define(INotificationDefinitionContext context) { - var tenantsGroup = context.AddGroup( - TenantNotificationNames.GroupName, - L("Notifications:MultiTenancy"), - false); - - tenantsGroup.AddNotification( - TenantNotificationNames.NewTenantRegistered, - L("Notifications:NewTenantRegisterd"), - L("Notifications:NewTenantRegisterd"), - notificationType: NotificationType.System, - lifetime: NotificationLifetime.OnlyOne, - allowSubscriptionToClients: false - ) - .WithProviders( - NotificationProviderNames.SignalR, - NotificationProviderNames.Emailing) - .WithProperty("Template", "NewTenantRegisterd"); - - var usersGroup = context.AddGroup( - UserNotificationNames.GroupName, - L("Notifications:Users")); - - usersGroup.AddNotification( - UserNotificationNames.WelcomeToApplication, - L("Notifications:WelcomeToApplication"), - L("Notifications:WelcomeToApplication"), - notificationType: NotificationType.System, - lifetime: NotificationLifetime.OnlyOne, - allowSubscriptionToClients: true) - .WithProviders( - NotificationProviderNames.SignalR, - NotificationProviderNames.Emailing) - .WithProperty("Template", "WelcomeToApplication"); - var imGroup = context.AddGroup( MessageServiceNotificationNames.IM.GroupName, L("Notifications:IM")); 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 deleted file mode 100644 index 0011079cf..000000000 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationTemplate.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Volo.Abp.Domain.Entities.Auditing; - -namespace LINGYUN.Abp.MessageService.Notifications; - -public class NotificationTemplate : AuditedAggregateRoot -{ - -} 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..544802d7b 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,7 @@ namespace LINGYUN.Abp.MessageService.EntityFrameworkCore context.Services.AddAbpDbContext(options => { options.AddRepository(); + options.AddRepository(); options.AddRepository(); 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..3e9b5250d 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,16 @@ namespace LINGYUN.Abp.MessageService.Notifications } [HttpPost] - public virtual async Task SendAsync(NotificationSendDto input) + public async virtual Task SendAsync(NotificationSendDto input) { await NotificationAppService.SendAsync(input); } + + [HttpGet] + [Route("assignable-templates")] + public async virtual Task> GetAssignableTemplatesAsync() + { + return await NotificationAppService.GetAssignableTemplatesAsync(); + } } } diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/FodyWeavers.xml b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/FodyWeavers.xml new file mode 100644 index 000000000..17d32672d --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/FodyWeavers.xsd b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/FodyWeavers.xsd new file mode 100644 index 000000000..11da52550 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/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/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/LINGYUN.Abp.TextTemplating.Application.Contracts.csproj b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/LINGYUN.Abp.TextTemplating.Application.Contracts.csproj new file mode 100644 index 000000000..45b2cf3c7 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/LINGYUN.Abp.TextTemplating.Application.Contracts.csproj @@ -0,0 +1,24 @@ + + + + netstandard2.0 + + + + + + + netstandard2.0 + + + + + + + + + + + + + diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/LINGYUN/Abp/TextTemplating/AbpTextTemplatingApplicationContractsModule.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/LINGYUN/Abp/TextTemplating/AbpTextTemplatingApplicationContractsModule.cs new file mode 100644 index 000000000..7d831e1f3 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/LINGYUN/Abp/TextTemplating/AbpTextTemplatingApplicationContractsModule.cs @@ -0,0 +1,14 @@ +using Volo.Abp.Application; +using Volo.Abp.Authorization; +using Volo.Abp.Modularity; + +namespace LINGYUN.Abp.TextTemplating; + +[DependsOn( + typeof(AbpTextTemplatingDomainSharedModule), + typeof(AbpAuthorizationAbstractionsModule), + typeof(AbpDddApplicationContractsModule))] +public class AbpTextTemplatingApplicationContractsModule : AbpModule +{ + +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/LINGYUN/Abp/TextTemplating/AbpTextTemplatingRemoteServiceConsts.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/LINGYUN/Abp/TextTemplating/AbpTextTemplatingRemoteServiceConsts.cs new file mode 100644 index 000000000..af80a87d5 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/LINGYUN/Abp/TextTemplating/AbpTextTemplatingRemoteServiceConsts.cs @@ -0,0 +1,8 @@ +namespace LINGYUN.Abp.TextTemplating; + +public class AbpTextTemplatingRemoteServiceConsts +{ + public const string RemoteServiceName = "AbpTextTemplating"; + + public const string ModuleName = "text-templating"; +} \ No newline at end of file diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/LINGYUN/Abp/TextTemplating/ITextTemplateAppService.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/LINGYUN/Abp/TextTemplating/ITextTemplateAppService.cs new file mode 100644 index 000000000..287111b29 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/LINGYUN/Abp/TextTemplating/ITextTemplateAppService.cs @@ -0,0 +1,16 @@ +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; + +namespace LINGYUN.Abp.TextTemplating; + +public interface ITextTemplateAppService : IApplicationService +{ + Task GetAsync(TextTemplateGetInput input); + + Task ResetDefaultAsync(TextTemplateGetInput input); + + Task UpdateAsync(TextTemplateUpdateInput input); + + Task> GetListAsync(); +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/LINGYUN/Abp/TextTemplating/Permissions/AbpTextTemplatingPermissionDefinitionProvider.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/LINGYUN/Abp/TextTemplating/Permissions/AbpTextTemplatingPermissionDefinitionProvider.cs new file mode 100644 index 000000000..8e1f568ae --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/LINGYUN/Abp/TextTemplating/Permissions/AbpTextTemplatingPermissionDefinitionProvider.cs @@ -0,0 +1,23 @@ +using LINGYUN.Abp.TextTemplating.Localization; +using Volo.Abp.Authorization.Permissions; +using Volo.Abp.Localization; + +namespace LINGYUN.Abp.TextTemplating; + +public class AbpTextTemplatingPermissionDefinitionProvider : PermissionDefinitionProvider +{ + public override void Define(IPermissionDefinitionContext context) + { + var saasGroup = context.AddGroup(AbpTextTemplatingPermissions.GroupName, L("Permission:Saas")); + + var textTemplatePermission = saasGroup.AddPermission(AbpTextTemplatingPermissions.TextTemplate.Default, L("Permission:TextTemplates")); + textTemplatePermission.AddChild(AbpTextTemplatingPermissions.TextTemplate.Create, L("Permission:Create")); + textTemplatePermission.AddChild(AbpTextTemplatingPermissions.TextTemplate.Update, L("Permission:Edit")); + textTemplatePermission.AddChild(AbpTextTemplatingPermissions.TextTemplate.Delete, L("Permission:Delete")); + } + + private static LocalizableString L(string name) + { + return LocalizableString.Create(name); + } +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/LINGYUN/Abp/TextTemplating/Permissions/AbpTextTemplatingPermissions.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/LINGYUN/Abp/TextTemplating/Permissions/AbpTextTemplatingPermissions.cs new file mode 100644 index 000000000..db9dbfdbd --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/LINGYUN/Abp/TextTemplating/Permissions/AbpTextTemplatingPermissions.cs @@ -0,0 +1,21 @@ +using Volo.Abp.Reflection; + +namespace LINGYUN.Abp.TextTemplating; + +public static class AbpTextTemplatingPermissions +{ + public const string GroupName = "AbpTextTemplating"; + + public static class TextTemplate + { + public const string Default = GroupName + ".TextTemplates"; + public const string Create = Default + ".Create"; + public const string Update = Default + ".Update"; + public const string Delete = Default + ".Delete"; + } + + public static string[] GetAll() + { + return ReflectionHelper.GetPublicConstantsRecursively(typeof(AbpTextTemplatingPermissions)); + } +} \ No newline at end of file diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/LINGYUN/Abp/TextTemplating/TextTemplateDto.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/LINGYUN/Abp/TextTemplating/TextTemplateDto.cs new file mode 100644 index 000000000..664dde8f4 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/LINGYUN/Abp/TextTemplating/TextTemplateDto.cs @@ -0,0 +1,9 @@ +namespace LINGYUN.Abp.TextTemplating; + +public class TextTemplateDto +{ + public string Name { get; set; } + public string DisplayName { get; set; } + public string Content { get; set; } + public string Culture { get; set; } +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/LINGYUN/Abp/TextTemplating/TextTemplateGetInput.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/LINGYUN/Abp/TextTemplating/TextTemplateGetInput.cs new file mode 100644 index 000000000..a863d62c6 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/LINGYUN/Abp/TextTemplating/TextTemplateGetInput.cs @@ -0,0 +1,14 @@ +using System.ComponentModel.DataAnnotations; +using Volo.Abp.Validation; + +namespace LINGYUN.Abp.TextTemplating; + +public class TextTemplateGetInput +{ + [Required] + [DynamicStringLength(typeof(TextTemplateConsts), nameof(TextTemplateConsts.MaxNameLength))] + public string Name { get; set; } + + [DynamicStringLength(typeof(TextTemplateConsts), nameof(TextTemplateConsts.MaxCultureLength))] + public string Culture { get; set; } +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/LINGYUN/Abp/TextTemplating/TextTemplateUpdateInput.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/LINGYUN/Abp/TextTemplating/TextTemplateUpdateInput.cs new file mode 100644 index 000000000..a8804ec1c --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application.Contracts/LINGYUN/Abp/TextTemplating/TextTemplateUpdateInput.cs @@ -0,0 +1,19 @@ +using System.ComponentModel.DataAnnotations; +using Volo.Abp.Validation; + +namespace LINGYUN.Abp.TextTemplating; + +public class TextTemplateUpdateInput +{ + [Required] + [DynamicStringLength(typeof(TextTemplateConsts), nameof(TextTemplateConsts.MaxNameLength))] + public string Name { get; set; } + + [Required] + [DynamicStringLength(typeof(TextTemplateConsts), nameof(TextTemplateConsts.MaxCultureLength))] + public string Culture { get; set; } + + [Required] + [DynamicStringLength(typeof(TextTemplateConsts), nameof(TextTemplateConsts.MaxContentLength))] + public string Content { get; set; } +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application/FodyWeavers.xml b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application/FodyWeavers.xml new file mode 100644 index 000000000..17d32672d --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application/FodyWeavers.xsd b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application/FodyWeavers.xsd new file mode 100644 index 000000000..11da52550 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application/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/text-templating/LINGYUN.Abp.TextTemplating.Application/LINGYUN.Abp.TextTemplating.Application.csproj b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application/LINGYUN.Abp.TextTemplating.Application.csproj new file mode 100644 index 000000000..7a8d8a78f --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application/LINGYUN.Abp.TextTemplating.Application.csproj @@ -0,0 +1,21 @@ + + + + + + + netstandard2.1 + + + + + + + + + + + + + + diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application/LINGYUN/Abp/TextTemplating/AbpTextTemplatingAppServiceBase.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application/LINGYUN/Abp/TextTemplating/AbpTextTemplatingAppServiceBase.cs new file mode 100644 index 000000000..ae5f66ecf --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application/LINGYUN/Abp/TextTemplating/AbpTextTemplatingAppServiceBase.cs @@ -0,0 +1,13 @@ +using LINGYUN.Abp.TextTemplating.Localization; +using Volo.Abp.Application.Services; + +namespace LINGYUN.Abp.TextTemplating; + +public abstract class AbpTextTemplatingAppServiceBase : ApplicationService +{ + protected AbpTextTemplatingAppServiceBase() + { + ObjectMapperContext = typeof(AbpTextTemplatingApplicationModule); + LocalizationResource = typeof(AbpTextTemplatingResource); + } +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application/LINGYUN/Abp/TextTemplating/AbpTextTemplatingApplicationAutoMapperProfile.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application/LINGYUN/Abp/TextTemplating/AbpTextTemplatingApplicationAutoMapperProfile.cs new file mode 100644 index 000000000..5360f8525 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application/LINGYUN/Abp/TextTemplating/AbpTextTemplatingApplicationAutoMapperProfile.cs @@ -0,0 +1,11 @@ +using AutoMapper; + +namespace LINGYUN.Abp.TextTemplating; + +public class AbpTextTemplatingApplicationAutoMapperProfile : Profile +{ + public AbpTextTemplatingApplicationAutoMapperProfile() + { + CreateMap(); + } +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application/LINGYUN/Abp/TextTemplating/AbpTextTemplatingApplicationModule.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application/LINGYUN/Abp/TextTemplating/AbpTextTemplatingApplicationModule.cs new file mode 100644 index 000000000..5ab7ee8a0 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application/LINGYUN/Abp/TextTemplating/AbpTextTemplatingApplicationModule.cs @@ -0,0 +1,23 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Application; +using Volo.Abp.AutoMapper; +using Volo.Abp.Modularity; + +namespace LINGYUN.Abp.TextTemplating; + +[DependsOn( + typeof(AbpTextTemplatingDomainModule), + typeof(AbpTextTemplatingApplicationContractsModule), + typeof(AbpAutoMapperModule), + typeof(AbpDddApplicationModule))] +public class AbpTextTemplatingApplicationModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddAutoMapperObjectMapper(); + Configure(options => + { + options.AddProfile(validate: true); + }); + } +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application/LINGYUN/Abp/TextTemplating/TextTemplateAppService.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application/LINGYUN/Abp/TextTemplating/TextTemplateAppService.cs new file mode 100644 index 000000000..0eccb770a --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application/LINGYUN/Abp/TextTemplating/TextTemplateAppService.cs @@ -0,0 +1,135 @@ +using Microsoft.AspNetCore.Authorization; +using System.Collections.Generic; +using System.Globalization; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Localization; +using Volo.Abp.TextTemplating; + +namespace LINGYUN.Abp.TextTemplating; + +[Authorize(AbpTextTemplatingPermissions.TextTemplate.Default)] +public class TextTemplateAppService : AbpTextTemplatingAppServiceBase, ITextTemplateAppService +{ + protected ITextTemplateRepository TextTemplateRepository { get; } + protected ITemplateContentProvider TemplateContentProvider { get; } + protected ITemplateDefinitionManager TemplateDefinitionManager { get; } + + public TextTemplateAppService( + ITextTemplateRepository textTemplateRepository, + ITemplateContentProvider templateContentProvider, + ITemplateDefinitionManager templateDefinitionManager) + { + TextTemplateRepository = textTemplateRepository; + TemplateContentProvider = templateContentProvider; + TemplateDefinitionManager = templateDefinitionManager; + } + + public async virtual Task GetAsync(TextTemplateGetInput input) + { + + var templateDefinition = GetTemplateDefinition(input.Name); + + var culture = input.Culture ?? CultureInfo.CurrentCulture.Name ?? templateDefinition.DefaultCultureName; + + using (CultureHelper.Use(culture, culture)) + { + var content = await TemplateContentProvider.GetContentOrNullAsync(templateDefinition.Name, culture); + + return new TextTemplateDto + { + Culture = culture, + Content = content, + Name = templateDefinition.Name, + DisplayName = templateDefinition.DisplayName.Localize(StringLocalizerFactory), + }; + } + } + + public Task> GetListAsync() + { + var templates = new List(); + var templateDefinitions = TemplateDefinitionManager.GetAll(); + + foreach (var templateDefinition in templateDefinitions) + { + templates.Add( + new TextTemplateDto + { + Name = templateDefinition.Name, + Culture = CultureInfo.CurrentCulture.Name ?? templateDefinition.DefaultCultureName, + DisplayName = templateDefinition.DisplayName.Localize(StringLocalizerFactory), + }); + } + + return Task.FromResult(new ListResultDto(templates)); + } + + [Authorize(AbpTextTemplatingPermissions.TextTemplate.Delete)] + public async virtual Task ResetDefaultAsync(TextTemplateGetInput input) + { + var templateDefinition = GetTemplateDefinition(input.Name); + + var culture = input.Culture ?? CultureInfo.CurrentCulture.Name ?? templateDefinition.DefaultCultureName; + + using (CultureHelper.Use(culture, culture)) + { + var template = await TextTemplateRepository.FindByNameAsync( + templateDefinition.Name, + culture); + if (template != null) + { + await TextTemplateRepository.DeleteAsync(template); + } + } + } + + [Authorize(AbpTextTemplatingPermissions.TextTemplate.Update)] + public async virtual Task UpdateAsync(TextTemplateUpdateInput input) + { + var templateDefinition = GetTemplateDefinition(input.Name); + + var culture = input.Culture ?? CultureInfo.CurrentCulture.Name ?? templateDefinition.DefaultCultureName; + + using (CultureHelper.Use(culture, culture)) + { + var template = await TextTemplateRepository.FindByNameAsync(input.Name, culture); + if (template == null) + { + template = new TextTemplate( + GuidGenerator.Create(), + templateDefinition.Name, + templateDefinition.DisplayName.Localize(StringLocalizerFactory), + input.Content, + culture); + + template = await TextTemplateRepository.InsertAsync(template); + } + else + { + template.SetContent(input.Content); + + await TextTemplateRepository.UpdateAsync(template); + } + + await CurrentUnitOfWork.SaveChangesAsync(); + + return ObjectMapper.Map(template); + } + } + + protected virtual TemplateDefinition GetTemplateDefinition(string name) + { + var template = TemplateDefinitionManager.GetOrNull(name); + if (template == null) + { + throw new BusinessException( + AbpTextTemplatingErrorCodes.TemplateNotFound, + $"The text template {name} does not exist!") + .WithData("Name", name); + } + + return template; + } +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/FodyWeavers.xml b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/FodyWeavers.xml new file mode 100644 index 000000000..c485a4548 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/FodyWeavers.xsd b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/FodyWeavers.xsd new file mode 100644 index 000000000..11da52550 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/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/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/LINGYUN.Abp.TextTemplating.Domain.Shared.csproj b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/LINGYUN.Abp.TextTemplating.Domain.Shared.csproj new file mode 100644 index 000000000..9c44b07af --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/LINGYUN.Abp.TextTemplating.Domain.Shared.csproj @@ -0,0 +1,20 @@ + + + + + + + netstandard2.0 + + + + + + + + + + + + + diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/LINGYUN/Abp/TextTemplating/AbpTextTemplatingDomainSharedModule.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/LINGYUN/Abp/TextTemplating/AbpTextTemplatingDomainSharedModule.cs new file mode 100644 index 000000000..64cd26226 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/LINGYUN/Abp/TextTemplating/AbpTextTemplatingDomainSharedModule.cs @@ -0,0 +1,33 @@ +using LINGYUN.Abp.TextTemplating.Localization; +using Volo.Abp.Localization; +using Volo.Abp.Localization.ExceptionHandling; +using Volo.Abp.Modularity; +using Volo.Abp.Validation; +using Volo.Abp.VirtualFileSystem; + +namespace LINGYUN.Abp.TextTemplating; + +[DependsOn( + typeof(AbpValidationModule))] +public class AbpTextTemplatingDomainSharedModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.FileSets.AddEmbedded(); + }); + + Configure(options => + { + options.Resources + .Add("en") + .AddVirtualJson("/LINGYUN/Abp/TextTemplating/Localization/Resources"); + }); + + Configure(options => + { + options.MapCodeNamespace(AbpTextTemplatingErrorCodes.Namespace, typeof(AbpTextTemplatingResource)); + }); + } +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/LINGYUN/Abp/TextTemplating/AbpTextTemplatingErrorCodes.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/LINGYUN/Abp/TextTemplating/AbpTextTemplatingErrorCodes.cs new file mode 100644 index 000000000..d3dc1e466 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/LINGYUN/Abp/TextTemplating/AbpTextTemplatingErrorCodes.cs @@ -0,0 +1,11 @@ +namespace LINGYUN.Abp.TextTemplating; + +public static class AbpTextTemplatingErrorCodes +{ + public const string Namespace = "TextTemplating"; + + /// + /// 模板不存在! + /// + public const string TemplateNotFound = Namespace + ":01404"; +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/LINGYUN/Abp/TextTemplating/Localization/AbpTextTemplatingResource.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/LINGYUN/Abp/TextTemplating/Localization/AbpTextTemplatingResource.cs new file mode 100644 index 000000000..eb4b6610c --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/LINGYUN/Abp/TextTemplating/Localization/AbpTextTemplatingResource.cs @@ -0,0 +1,8 @@ +using Volo.Abp.Localization; + +namespace LINGYUN.Abp.TextTemplating.Localization; + +[LocalizationResourceName("AbpTextTemplating")] +public class AbpTextTemplatingResource +{ +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/LINGYUN/Abp/TextTemplating/Localization/Resources/en.json b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/LINGYUN/Abp/TextTemplating/Localization/Resources/en.json new file mode 100644 index 000000000..a9c8dcc3f --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/LINGYUN/Abp/TextTemplating/Localization/Resources/en.json @@ -0,0 +1,5 @@ +{ + "culture": "en", + "texts": { + } +} \ No newline at end of file diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/LINGYUN/Abp/TextTemplating/Localization/Resources/zh-Hans.json b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/LINGYUN/Abp/TextTemplating/Localization/Resources/zh-Hans.json new file mode 100644 index 000000000..c5ad81326 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/LINGYUN/Abp/TextTemplating/Localization/Resources/zh-Hans.json @@ -0,0 +1,5 @@ +{ + "culture": "zh-Hans", + "texts": { + } +} \ No newline at end of file diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/LINGYUN/Abp/TextTemplating/TextTemplateConsts.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/LINGYUN/Abp/TextTemplating/TextTemplateConsts.cs new file mode 100644 index 000000000..903e0f7fa --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain.Shared/LINGYUN/Abp/TextTemplating/TextTemplateConsts.cs @@ -0,0 +1,12 @@ +namespace LINGYUN.Abp.TextTemplating; + +public static class TextTemplateConsts +{ + public static int MaxNameLength { get; set; } = 100; + + public static int MaxDisplayNameLength { get; set; } = 100; + + public static int MaxContentLength { get; set; } = 1024 * 1024; + + public static int MaxCultureLength { get; set; } = 30; +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/FodyWeavers.xml b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/FodyWeavers.xml new file mode 100644 index 000000000..c485a4548 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/FodyWeavers.xsd b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/FodyWeavers.xsd new file mode 100644 index 000000000..11da52550 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/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.csproj b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN.Abp.TextTemplating.Domain.csproj similarity index 63% rename from aspnet-core/modules/common/LINGYUN.Abp.Notifications.TextTemplating/LINGYUN.Abp.Notifications.TextTemplating.csproj rename to aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN.Abp.TextTemplating.Domain.csproj index 3f15a30e1..fc31bc931 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.TextTemplating/LINGYUN.Abp.Notifications.TextTemplating.csproj +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN.Abp.TextTemplating.Domain.csproj @@ -9,11 +9,11 @@ + - + - diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/AbpTextTemplatingDbProperties.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/AbpTextTemplatingDbProperties.cs new file mode 100644 index 000000000..c4ecb380c --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/AbpTextTemplatingDbProperties.cs @@ -0,0 +1,12 @@ +using Volo.Abp.Data; + +namespace LINGYUN.Abp.TextTemplating; + +public class AbpTextTemplatingDbProperties +{ + public static string DbTablePrefix { get; set; } = AbpCommonDbProperties.DbTablePrefix; + + public static string DbSchema { get; set; } = AbpCommonDbProperties.DbSchema; + + public const string ConnectionStringName = "AbpTextTemplating"; +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/AbpTextTemplatingDomainModule.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/AbpTextTemplatingDomainModule.cs new file mode 100644 index 000000000..0bba602d8 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/AbpTextTemplatingDomainModule.cs @@ -0,0 +1,12 @@ +using Volo.Abp.Modularity; +using Volo.Abp.TextTemplating; + +namespace LINGYUN.Abp.TextTemplating; + +[DependsOn( + typeof(AbpTextTemplatingDomainSharedModule), + typeof(AbpTextTemplatingCoreModule))] +public class AbpTextTemplatingDomainModule : AbpModule +{ + +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/ITextTemplateRepository.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/ITextTemplateRepository.cs new file mode 100644 index 000000000..a9abd556a --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/ITextTemplateRepository.cs @@ -0,0 +1,11 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories; + +namespace LINGYUN.Abp.TextTemplating; + +public interface ITextTemplateRepository : IBasicRepository +{ + Task FindByNameAsync(string name, string culture = null, CancellationToken cancellationToken = default); +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TextTemplate.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TextTemplate.cs new file mode 100644 index 000000000..a0b49d0b7 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TextTemplate.cs @@ -0,0 +1,34 @@ +using System; +using Volo.Abp; +using Volo.Abp.Domain.Entities.Auditing; +using Volo.Abp.MultiTenancy; + +namespace LINGYUN.Abp.TextTemplating; + +public class TextTemplate : AuditedEntity, IMultiTenant +{ + public virtual Guid? TenantId { get; protected set; } + public virtual string Name { get; private set; } + public virtual string DisplayName { get; private set; } + public virtual string Content { get; private set; } + public virtual string Culture { get; private set; } + protected TextTemplate() { } + public TextTemplate( + Guid id, + string name, + string displayName, + string content, + string culture) + : base(id) + { + Name = Check.NotNullOrWhiteSpace(name, nameof(name), TextTemplateConsts.MaxNameLength); + DisplayName = Check.NotNullOrWhiteSpace(displayName, nameof(displayName), TextTemplateConsts.MaxDisplayNameLength); + Content = Check.NotNullOrWhiteSpace(content, nameof(content), TextTemplateConsts.MaxContentLength); + Culture = Check.NotNullOrWhiteSpace(culture, nameof(culture), TextTemplateConsts.MaxCultureLength); + } + + public void SetContent(string content) + { + Content = Check.NotNullOrWhiteSpace(content, nameof(content), TextTemplateConsts.MaxContentLength); + } +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TextTemplateContentContributor.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TextTemplateContentContributor.cs new file mode 100644 index 000000000..0fd44ce09 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Domain/LINGYUN/Abp/TextTemplating/TextTemplateContentContributor.cs @@ -0,0 +1,17 @@ +using Microsoft.Extensions.DependencyInjection; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Volo.Abp.TextTemplating; + +namespace LINGYUN.Abp.TextTemplating; + +public class TextTemplateContentContributor : ITemplateContentContributor, ITransientDependency +{ + public async virtual Task GetOrNullAsync(TemplateContentContributorContext context) + { + var repository = context.ServiceProvider.GetRequiredService(); + var template = await repository.FindByNameAsync(context.TemplateDefinition.Name, context.Culture); + + return template?.Content; + } +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/FodyWeavers.xml b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/FodyWeavers.xml new file mode 100644 index 000000000..c485a4548 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/FodyWeavers.xsd b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/FodyWeavers.xsd new file mode 100644 index 000000000..11da52550 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/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/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN.Abp.TextTemplating.EntityFrameworkCore.csproj b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN.Abp.TextTemplating.EntityFrameworkCore.csproj new file mode 100644 index 000000000..c4657dd38 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN.Abp.TextTemplating.EntityFrameworkCore.csproj @@ -0,0 +1,19 @@ + + + + + + + net6.0 + + + + + + + + + + + + diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN/Abp/TextTemplating/AbpTextTemplatingDbContextModelCreatingExtensions.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN/Abp/TextTemplating/AbpTextTemplatingDbContextModelCreatingExtensions.cs new file mode 100644 index 000000000..15ef452dc --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN/Abp/TextTemplating/AbpTextTemplatingDbContextModelCreatingExtensions.cs @@ -0,0 +1,45 @@ +using Microsoft.EntityFrameworkCore; +using Volo.Abp; +using Volo.Abp.EntityFrameworkCore.Modeling; + +namespace LINGYUN.Abp.TextTemplating.EntityFrameworkCore; + +public static class AbpTextTemplatingDbContextModelCreatingExtensions +{ + public static void ConfigureTextTemplating( + this ModelBuilder builder) + { + Check.NotNull(builder, nameof(builder)); + + builder.Entity(b => + { + b.ToTable(AbpTextTemplatingDbProperties.DbTablePrefix + "TextTemplates", AbpTextTemplatingDbProperties.DbSchema); + + b.ConfigureByConvention(); + + b.Property(t => t.Name) + .HasColumnName(nameof(TextTemplate.Name)) + .HasMaxLength(TextTemplateConsts.MaxNameLength) + .IsRequired(); + b.Property(t => t.DisplayName) + .HasColumnName(nameof(TextTemplate.DisplayName)) + .HasMaxLength(TextTemplateConsts.MaxDisplayNameLength) + .IsRequired(); + b.Property(t => t.Culture) + .HasColumnName(nameof(TextTemplate.Culture)) + .HasMaxLength(TextTemplateConsts.MaxCultureLength) + .IsRequired(); + + b.Property(t => t.Content) + .HasColumnName(nameof(TextTemplate.Content)) + .HasMaxLength(TextTemplateConsts.MaxContentLength); + + b.HasIndex(p => new { p.TenantId, p.Name }) + .HasDatabaseName("IX_Tenant_Text_Template_Name"); + + b.ApplyObjectExtensionMappings(); + }); + + builder.TryConfigureObjectExtensions(); + } +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN/Abp/TextTemplating/AbpTextTemplatingEntityFrameworkCoreModule.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN/Abp/TextTemplating/AbpTextTemplatingEntityFrameworkCoreModule.cs new file mode 100644 index 000000000..f6f308316 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN/Abp/TextTemplating/AbpTextTemplatingEntityFrameworkCoreModule.cs @@ -0,0 +1,21 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.Modularity; + +namespace LINGYUN.Abp.TextTemplating.EntityFrameworkCore; + +[DependsOn( + typeof(AbpTextTemplatingDomainModule), + typeof(AbpEntityFrameworkCoreModule))] +public class AbpTextTemplatingEntityFrameworkCoreModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddAbpDbContext(options => + { + options.AddRepository(); + + options.AddDefaultRepositories(); + }); + } +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN/Abp/TextTemplating/EfCoreTextTemplateRepository.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN/Abp/TextTemplating/EfCoreTextTemplateRepository.cs new file mode 100644 index 000000000..bf4dd4992 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN/Abp/TextTemplating/EfCoreTextTemplateRepository.cs @@ -0,0 +1,31 @@ +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.TextTemplating.EntityFrameworkCore; + +public class EfCoreTextTemplateRepository : + EfCoreRepository, + ITextTemplateRepository, + ITransientDependency +{ + public EfCoreTextTemplateRepository( + IDbContextProvider dbContextProvider) + : base(dbContextProvider) + { + } + + public async virtual Task FindByNameAsync(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/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN/Abp/TextTemplating/ITextTemplatingDbContext.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN/Abp/TextTemplating/ITextTemplatingDbContext.cs new file mode 100644 index 000000000..dab92e53e --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN/Abp/TextTemplating/ITextTemplatingDbContext.cs @@ -0,0 +1,13 @@ +using Microsoft.EntityFrameworkCore; +using Volo.Abp.Data; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.MultiTenancy; + +namespace LINGYUN.Abp.TextTemplating.EntityFrameworkCore; + +[IgnoreMultiTenancy] +[ConnectionStringName(AbpTextTemplatingDbProperties.ConnectionStringName)] +public interface ITextTemplatingDbContext : IEfCoreDbContext +{ + DbSet TextTemplates { get; } +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN/Abp/TextTemplating/TextTemplatingDbContext.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN/Abp/TextTemplating/TextTemplatingDbContext.cs new file mode 100644 index 000000000..120b0527f --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN/Abp/TextTemplating/TextTemplatingDbContext.cs @@ -0,0 +1,25 @@ +using Microsoft.EntityFrameworkCore; +using Volo.Abp.Data; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.MultiTenancy; + +namespace LINGYUN.Abp.TextTemplating.EntityFrameworkCore; + +[IgnoreMultiTenancy] +[ConnectionStringName(AbpTextTemplatingDbProperties.ConnectionStringName)] +public class TextTemplatingDbContext : AbpDbContext, ITextTemplatingDbContext +{ + public DbSet TextTemplates { get; set; } + + public TextTemplatingDbContext(DbContextOptions options) + : base(options) + { + } + + protected override void OnModelCreating(ModelBuilder builder) + { + base.OnModelCreating(builder); + + builder.ConfigureTextTemplating(); + } +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN/Abp/TextTemplating/TextTemplatingEfCoreQueryableExtensions.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN/Abp/TextTemplating/TextTemplatingEfCoreQueryableExtensions.cs new file mode 100644 index 000000000..f439a71fc --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.EntityFrameworkCore/LINGYUN/Abp/TextTemplating/TextTemplatingEfCoreQueryableExtensions.cs @@ -0,0 +1,5 @@ +namespace LINGYUN.Abp.TextTemplating.EntityFrameworkCore; + +public static class TextTemplatingEfCoreQueryableExtensions +{ +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi.Client/FodyWeavers.xml b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi.Client/FodyWeavers.xml new file mode 100644 index 000000000..c485a4548 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi.Client/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi.Client/FodyWeavers.xsd b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi.Client/FodyWeavers.xsd new file mode 100644 index 000000000..11da52550 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi.Client/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/text-templating/LINGYUN.Abp.TextTemplating.HttpApi.Client/LINGYUN.Abp.TextTemplating.HttpApi.Client.csproj b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi.Client/LINGYUN.Abp.TextTemplating.HttpApi.Client.csproj new file mode 100644 index 000000000..985b97d4c --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi.Client/LINGYUN.Abp.TextTemplating.HttpApi.Client.csproj @@ -0,0 +1,19 @@ + + + + + + + netstandard2.0 + + + + + + + + + + + + diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi.Client/LINGYUN/Abp/TextTemplating/AbpTextTemplatingHttpApiClientModule.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi.Client/LINGYUN/Abp/TextTemplating/AbpTextTemplatingHttpApiClientModule.cs new file mode 100644 index 000000000..96a398c6e --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi.Client/LINGYUN/Abp/TextTemplating/AbpTextTemplatingHttpApiClientModule.cs @@ -0,0 +1,19 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Http.Client; +using Volo.Abp.Modularity; + +namespace LINGYUN.Abp.TextTemplating; + +[DependsOn( + typeof(AbpTextTemplatingApplicationContractsModule), + typeof(AbpHttpClientModule))] +public class AbpTextTemplatingHttpApiClientModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddHttpClientProxies( + typeof(AbpTextTemplatingApplicationContractsModule).Assembly, + AbpTextTemplatingRemoteServiceConsts.RemoteServiceName + ); + } +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi/FodyWeavers.xml b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi/FodyWeavers.xml new file mode 100644 index 000000000..c485a4548 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi/FodyWeavers.xsd b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi/FodyWeavers.xsd new file mode 100644 index 000000000..11da52550 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi/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/text-templating/LINGYUN.Abp.TextTemplating.HttpApi/LINGYUN.Abp.TextTemplating.HttpApi.csproj b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi/LINGYUN.Abp.TextTemplating.HttpApi.csproj new file mode 100644 index 000000000..8e0fea148 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi/LINGYUN.Abp.TextTemplating.HttpApi.csproj @@ -0,0 +1,19 @@ + + + + + + + net6.0 + + + + + + + + + + + + diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi/LINGYUN/Abp/TextTemplating/AbpTextTemplatingControllerBase.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi/LINGYUN/Abp/TextTemplating/AbpTextTemplatingControllerBase.cs new file mode 100644 index 000000000..ba0ea8413 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi/LINGYUN/Abp/TextTemplating/AbpTextTemplatingControllerBase.cs @@ -0,0 +1,12 @@ +using LINGYUN.Abp.TextTemplating.Localization; +using Volo.Abp.AspNetCore.Mvc; + +namespace LINGYUN.Abp.TextTemplating; + +public abstract class AbpTextTemplatingControllerBase : AbpControllerBase +{ + protected AbpTextTemplatingControllerBase() + { + LocalizationResource = typeof(AbpTextTemplatingResource); + } +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi/LINGYUN/Abp/TextTemplating/AbpTextTemplatingHttpApiModule.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi/LINGYUN/Abp/TextTemplating/AbpTextTemplatingHttpApiModule.cs new file mode 100644 index 000000000..74424eaa9 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi/LINGYUN/Abp/TextTemplating/AbpTextTemplatingHttpApiModule.cs @@ -0,0 +1,40 @@ +using LINGYUN.Abp.TextTemplating.Localization; +using Localization.Resources.AbpUi; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc.Localization; +using Volo.Abp.Localization; +using Volo.Abp.Modularity; + +namespace LINGYUN.Abp.TextTemplating; + +[DependsOn( + typeof(AbpTextTemplatingApplicationContractsModule), + typeof(AbpAspNetCoreMvcModule))] +public class AbpTextTemplatingHttpApiModule : AbpModule +{ + public override void PreConfigureServices(ServiceConfigurationContext context) + { + PreConfigure(mvcBuilder => + { + mvcBuilder.AddApplicationPartIfNotExists(typeof(AbpTextTemplatingHttpApiModule).Assembly); + }); + + PreConfigure(options => + { + options.AddAssemblyResource( + typeof(AbpTextTemplatingResource), + typeof(AbpTextTemplatingApplicationContractsModule).Assembly); + }); + } + + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.Resources + .Get() + .AddBaseTypes(typeof(AbpUiResource)); + }); + } +} diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi/LINGYUN/Abp/TextTemplating/TextTemplateController.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi/LINGYUN/Abp/TextTemplating/TextTemplateController.cs new file mode 100644 index 000000000..9c7f71641 --- /dev/null +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.HttpApi/LINGYUN/Abp/TextTemplating/TextTemplateController.cs @@ -0,0 +1,53 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Application.Dtos; + +namespace LINGYUN.Abp.TextTemplating; + +[Controller] +[Authorize(AbpTextTemplatingPermissions.TextTemplate.Default)] +[RemoteService(Name = AbpTextTemplatingRemoteServiceConsts.RemoteServiceName)] +[Area(AbpTextTemplatingRemoteServiceConsts.ModuleName)] +[Route("api/text-templating/templates")] +public class TextTemplateController : AbpTextTemplatingControllerBase, ITextTemplateAppService +{ + protected ITextTemplateAppService TextTemplateAppService { get; } + + public TextTemplateController( + ITextTemplateAppService textTemplateAppService) + { + TextTemplateAppService = textTemplateAppService; + } + + [HttpGet] + [Route("{Name}")] + [Route("{Culture}/{Name}")] + public Task GetAsync(TextTemplateGetInput input) + { + return TextTemplateAppService.GetAsync(input); + } + + [HttpGet] + public Task> GetListAsync() + { + return TextTemplateAppService.GetListAsync(); + } + + [HttpDelete] + [Route("{Name}")] + [Route("{Culture}/{Name}")] + [Authorize(AbpTextTemplatingPermissions.TextTemplate.Delete)] + public Task ResetDefaultAsync(TextTemplateGetInput input) + { + return TextTemplateAppService.ResetDefaultAsync(input); + } + + [HttpPost] + [Authorize(AbpTextTemplatingPermissions.TextTemplate.Update)] + public Task UpdateAsync(TextTemplateUpdateInput input) + { + return TextTemplateAppService.UpdateAsync(input); + } +} diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.Configure.cs index ac8d92932..53b5adbf7 100644 --- a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.Configure.cs @@ -326,6 +326,11 @@ public partial class BackendAdminHttpApiHostModule options.Audience = configuration["AuthServer:ApiName"]; }); + if (isDevelopment) + { + // services.AddAlwaysAllowAuthorization(); + } + if (!isDevelopment) { var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.cs index 927d353ce..b77eccd57 100644 --- a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.cs @@ -17,6 +17,8 @@ using LINGYUN.Abp.Serilog.Enrichers.Application; using LINGYUN.Abp.Serilog.Enrichers.UniqueId; using LINGYUN.Abp.SettingManagement; using LINGYUN.Abp.Sms.Aliyun; +using LINGYUN.Abp.TextTemplating; +using LINGYUN.Abp.TextTemplating.EntityFrameworkCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; @@ -59,6 +61,8 @@ namespace LY.MicroService.BackendAdmin; typeof(AbpAuditingHttpApiModule), typeof(AbpSaasApplicationModule), typeof(AbpSaasHttpApiModule), + typeof(AbpTextTemplatingApplicationModule), + typeof(AbpTextTemplatingHttpApiModule), typeof(AbpEntityFrameworkCoreMySQLModule), typeof(AbpIdentityEntityFrameworkCoreModule),// 用户角色权限需要引用包 typeof(AbpIdentityServerEntityFrameworkCoreModule), // 客户端权限需要引用包 @@ -70,6 +74,7 @@ namespace LY.MicroService.BackendAdmin; typeof(AbpPermissionManagementEntityFrameworkCoreModule), typeof(AbpFeatureManagementEntityFrameworkCoreModule), typeof(AbpLocalizationManagementEntityFrameworkCoreModule), + typeof(AbpTextTemplatingEntityFrameworkCoreModule), typeof(AbpDataDbMigratorModule), typeof(AbpAspNetCoreAuthenticationJwtBearerModule), typeof(AbpEmailingExceptionHandlingModule), diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/EntityFrameworkCore/BackendAdminMigrationsDbContext.cs b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/EntityFrameworkCore/BackendAdminMigrationsDbContext.cs index 04647134f..edec673ff 100644 --- a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/EntityFrameworkCore/BackendAdminMigrationsDbContext.cs +++ b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/EntityFrameworkCore/BackendAdminMigrationsDbContext.cs @@ -4,6 +4,7 @@ using Volo.Abp.FeatureManagement.EntityFrameworkCore; using Volo.Abp.PermissionManagement.EntityFrameworkCore; using Volo.Abp.SettingManagement.EntityFrameworkCore; using LINGYUN.Abp.Saas.EntityFrameworkCore; +using LINGYUN.Abp.TextTemplating.EntityFrameworkCore; namespace LY.MicroService.BackendAdmin.EntityFrameworkCore; @@ -23,5 +24,6 @@ public class BackendAdminMigrationsDbContext : AbpDbContext + + + diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Migrations/20220625063937_Add-Module-Text-Templating.Designer.cs b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Migrations/20220625063937_Add-Module-Text-Templating.Designer.cs new file mode 100644 index 000000000..e745525b3 --- /dev/null +++ b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Migrations/20220625063937_Add-Module-Text-Templating.Designer.cs @@ -0,0 +1,354 @@ +// +using System; +using LY.MicroService.BackendAdmin.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.BackendAdmin.Migrations +{ + [DbContext(typeof(BackendAdminMigrationsDbContext))] + [Migration("20220625063937_Add-Module-Text-Templating")] + partial class AddModuleTextTemplating + { + 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.Saas.Editions.Edition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + 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("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.HasKey("Id"); + + b.HasIndex("DisplayName"); + + b.ToTable("AbpEditions", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.Tenant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + 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("DeleterId") + .HasColumnType("char(36)") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("DisableTime") + .HasColumnType("datetime(6)"); + + b.Property("EditionId") + .HasColumnType("char(36)"); + + b.Property("EnableTime") + .HasColumnType("datetime(6)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.HasKey("Id"); + + b.HasIndex("EditionId"); + + b.HasIndex("Name"); + + b.ToTable("AbpTenants", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.TenantConnectionString", b => + { + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.Property("Name") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.HasKey("TenantId", "Name"); + + b.ToTable("AbpTenantConnectionStrings", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.TextTemplating.TextTemplate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Content") + .HasMaxLength(1048576) + .HasColumnType("longtext") + .HasColumnName("Content"); + + 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)") + .HasColumnName("Culture"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("DisplayName"); + + 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)") + .HasColumnName("Name"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Name") + .HasDatabaseName("IX_Tenant_Text_Template_Name"); + + b.ToTable("AbpTextTemplates", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureValue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ProviderKey") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ProviderName") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("Name", "ProviderName", "ProviderKey") + .IsUnique(); + + b.ToTable("AbpFeatureValues", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionGrant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ProviderKey") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ProviderName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Name", "ProviderName", "ProviderKey") + .IsUnique(); + + b.ToTable("AbpPermissionGrants", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.SettingManagement.Setting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ProviderKey") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ProviderName") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.HasKey("Id"); + + b.HasIndex("Name", "ProviderName", "ProviderKey") + .IsUnique(); + + b.ToTable("AbpSettings", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.Tenant", b => + { + b.HasOne("LINGYUN.Abp.Saas.Editions.Edition", "Edition") + .WithMany() + .HasForeignKey("EditionId"); + + b.Navigation("Edition"); + }); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.TenantConnectionString", b => + { + b.HasOne("LINGYUN.Abp.Saas.Tenants.Tenant", null) + .WithMany("ConnectionStrings") + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.Tenant", b => + { + b.Navigation("ConnectionStrings"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Migrations/20220625063937_Add-Module-Text-Templating.cs b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Migrations/20220625063937_Add-Module-Text-Templating.cs new file mode 100644 index 000000000..0a9d4efc9 --- /dev/null +++ b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Migrations/20220625063937_Add-Module-Text-Templating.cs @@ -0,0 +1,49 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LY.MicroService.BackendAdmin.Migrations +{ + public partial class AddModuleTextTemplating : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "AbpTextTemplates", + 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"), + DisplayName = table.Column(type: "varchar(100)", maxLength: 100, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Content = table.Column(type: "longtext", maxLength: 1048576, nullable: true) + .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_AbpTextTemplates", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_Tenant_Text_Template_Name", + table: "AbpTextTemplates", + columns: new[] { "TenantId", "Name" }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AbpTextTemplates"); + } + } +} diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Migrations/BackendAdminHostMigrationsDbContextModelSnapshot.cs b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Migrations/BackendAdminHostMigrationsDbContextModelSnapshot.cs index 86146a8dc..e56760307 100644 --- a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Migrations/BackendAdminHostMigrationsDbContextModelSnapshot.cs +++ b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Migrations/BackendAdminHostMigrationsDbContextModelSnapshot.cs @@ -18,7 +18,7 @@ namespace LY.MicroService.BackendAdmin.Migrations #pragma warning disable 612, 618 modelBuilder .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) - .HasAnnotation("ProductVersion", "6.0.3") + .HasAnnotation("ProductVersion", "6.0.6") .HasAnnotation("Relational:MaxIdentifierLength", 64); modelBuilder.Entity("LINGYUN.Abp.Saas.Editions.Edition", b => @@ -170,6 +170,63 @@ namespace LY.MicroService.BackendAdmin.Migrations b.ToTable("AbpTenantConnectionStrings", (string)null); }); + modelBuilder.Entity("LINGYUN.Abp.TextTemplating.TextTemplate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Content") + .HasMaxLength(1048576) + .HasColumnType("longtext") + .HasColumnName("Content"); + + 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)") + .HasColumnName("Culture"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("DisplayName"); + + 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)") + .HasColumnName("Name"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Name") + .HasDatabaseName("IX_Tenant_Text_Template_Name"); + + b.ToTable("AbpTextTemplates", (string)null); + }); + modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureValue", b => { b.Property("Id") diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/appsettings.Development.json b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/appsettings.Development.json index efd24f264..5c95c86dd 100644 --- a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/appsettings.Development.json +++ b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/appsettings.Development.json @@ -25,7 +25,8 @@ "AbpSettingManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", "AbpFeatureManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", "AbpPermissionManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", - "AbpLocalizationManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456" + "AbpLocalizationManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", + "AbpTextTemplating": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456" }, "CAP": { "EventBus": { 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 deleted file mode 100644 index 84a30254d..000000000 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/RealtimeMessageTemplateProvider.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Volo.Abp.TextTemplating; -using Volo.Abp.TextTemplating.Scriban; - -namespace LY.MicroService.RealtimeMessage.Emailing; - -public class RealtimeMessageTemplateProvider : TemplateDefinitionProvider -{ - public override void Define(ITemplateDefinitionContext context) - { - context.Add(CreateEmailTemplate()); - } - - protected virtual TemplateDefinition[] CreateEmailTemplate() - { - return new TemplateDefinition[] - { - new TemplateDefinition( - 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), - }; - } -} 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 deleted file mode 100644 index 38d937243..000000000 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/ExceptionNotifier/en.tpl +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - -
-
{{ header }} -
-
-
    -
  • Type  : {{ type }}
  • -
  • Message  : {{ message }}
  • -
  • Alarm level : {{ loglevel }}
  • -
  • TriggerTime : {{ createTime }}
  • -
-
- Stack trace -
-
-
{{ stacktrace }}
-
-
-
- {{ footer }} -
-
\ No newline at end of file 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 deleted file mode 100644 index 3d4b1e53d..000000000 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/ExceptionNotifier/zh-Hans.tpl +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - -
-
{{ header }} -
-
-
    -
  • 异常类型 : {{ title }}
  • -
  • 异常信息 : {{ message }}
  • -
  • 告警级别 : {{ loglevel }}
  • -
  • 触发时间 : {{ createTime }}
  • -
-
- 异常堆栈 -
-
-
{{ stacktrace }}
-
-
-
- {{ footer }} -
-
\ No newline at end of file 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 deleted file mode 100644 index 959d97561..000000000 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/NewTenantRegisterd/en.tpl +++ /dev/null @@ -1 +0,0 @@ -

A new tenant {{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 deleted file mode 100644 index 25f545dc8..000000000 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/NewTenantRegisterd/zh-Hans.tpl +++ /dev/null @@ -1 +0,0 @@ -

一个新的租户 {{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 deleted file mode 100644 index 2f5fa7959..000000000 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/WelcomeToApplication/en.tpl +++ /dev/null @@ -1 +0,0 @@ -

{{user}}, 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 deleted file mode 100644 index 2f5fa7959..000000000 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/WelcomeToApplication/zh-Hans.tpl +++ /dev/null @@ -1 +0,0 @@ -

{{user}}, Welcome to my application!

\ No newline at end of file diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/layout.tpl b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/layout.tpl deleted file mode 100644 index bdd5d22d8..000000000 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/layout.tpl +++ /dev/null @@ -1,10 +0,0 @@ - - - - - {{title}} - - - {{content}} - - \ 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..dffadccd6 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 @@ -7,10 +7,6 @@ - - - - @@ -52,6 +48,7 @@ + @@ -68,6 +65,7 @@ + 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..b11ea6638 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,612 @@ 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", "5.0.12") + .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("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); - b.Property("ExpirationTime") - .HasColumnType("datetime(6)"); + b.Property("ExpirationTime") + .HasColumnType("datetime(6)"); - b.Property("ExtraProperties") - .HasColumnType("longtext") - .HasColumnName("ExtraProperties"); + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); - b.Property("NotificationId") - .HasColumnType("bigint"); + b.Property("NotificationId") + .HasColumnType("bigint"); - b.Property("NotificationName") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("varchar(100)"); + b.Property("NotificationName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); - b.Property("NotificationTypeName") - .IsRequired() - .HasMaxLength(512) - .HasColumnType("varchar(512)"); + b.Property("NotificationTypeName") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("varchar(512)"); - b.Property("Severity") - .HasColumnType("tinyint"); + b.Property("Severity") + .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", "NotificationName"); + b.HasIndex("TenantId", "NotificationName"); - b.ToTable("AppNotifications"); - }); + b.ToTable("AppNotifications", (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.Configure.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs index 07acc3bec..f76d5a0a4 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs @@ -333,6 +333,11 @@ public partial class RealtimeMessageHttpApiHostModule }; }); + if (isDevelopment) + { + // services.AddAlwaysAllowAuthorization(); + } + if (!isDevelopment) { var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); 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..14272dbe2 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs @@ -14,6 +14,7 @@ using LINGYUN.Abp.Localization.CultureMap; using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; using LINGYUN.Abp.MessageService; using LINGYUN.Abp.MessageService.EntityFrameworkCore; +using LINGYUN.Abp.Notifications.Common; using LINGYUN.Abp.Notifications.Emailing; using LINGYUN.Abp.Notifications.SignalR; using LINGYUN.Abp.Notifications.Sms; @@ -22,6 +23,7 @@ using LINGYUN.Abp.Saas.EntityFrameworkCore; using LINGYUN.Abp.Serilog.Enrichers.Application; using LINGYUN.Abp.Serilog.Enrichers.UniqueId; using LINGYUN.Abp.TaskManagement.EntityFrameworkCore; +using LINGYUN.Abp.TextTemplating.EntityFrameworkCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; @@ -36,6 +38,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; @@ -57,16 +60,19 @@ namespace LY.MicroService.RealtimeMessage; typeof(AbpSettingManagementEntityFrameworkCoreModule), typeof(AbpPermissionManagementEntityFrameworkCoreModule), typeof(AbpLocalizationManagementEntityFrameworkCoreModule), + typeof(AbpTextTemplatingEntityFrameworkCoreModule), typeof(AbpDataDbMigratorModule), typeof(AbpAspNetCoreAuthenticationJwtBearerModule), typeof(AbpAuthorizationOrganizationUnitsModule), typeof(AbpBackgroundWorkersModule), typeof(AbpIMSignalRModule), + typeof(AbpNotificationsCommonModule), typeof(AbpNotificationsSmsModule), typeof(AbpNotificationsEmailingModule), typeof(AbpNotificationsSignalRModule), typeof(AbpNotificationsWeChatMiniProgramModule), typeof(AbpNotificationsExceptionHandlingModule), + typeof(AbpTextTemplatingScribanModule), typeof(AbpCAPEventBusModule), typeof(AbpCachingStackExchangeRedisModule), typeof(AbpAspNetCoreHttpOverridesModule), diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/appsettings.Development.json b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/appsettings.Development.json index 2b3bb333c..5786da2c9 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/appsettings.Development.json +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/appsettings.Development.json @@ -30,7 +30,8 @@ "AbpSaas": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", "AbpSettingManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", "AbpPermissionManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", - "AbpLocalizationManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456" + "AbpLocalizationManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", + "AbpTextTemplating": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456" }, "Redis": { "Configuration": "127.0.0.1,defaultDatabase=8", 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 diff --git a/build/modules.dependencies.json b/build/modules.dependencies.json index e550bd2fa..70bfd6eb9 100644 --- a/build/modules.dependencies.json +++ b/build/modules.dependencies.json @@ -22,7 +22,6 @@ "LINGYUN.Abp.IM.dll", "LINGYUN.Abp.MessageService.Domain.Shared.dll", "LINGYUN.Abp.RealTime.dll", - "LINGYUN.Abp.Notifications.dll", "LINGYUN.Platform.Application.Contracts.dll", "LINGYUN.Platform.Domain.Shared.dll", "LINGYUN.Abp.Tencent.dll", @@ -63,7 +62,9 @@ "LINGYUN.Abp.WorkflowManagement.Domain.Shared.dll", "LINGYUN.Abp.BackgroundTasks.Abstractions.dll", "LINGYUN.Abp.TaskManagement.Application.Contracts.dll", - "LINGYUN.Abp.TaskManagement.Domain.Shared.dll" + "LINGYUN.Abp.TaskManagement.Domain.Shared.dll", + "LINGYUN.Abp.Notifications.Common.dll", + "LINGYUN.Abp.Notifications.dll" ] } ]