committed by
GitHub
125 changed files with 2640 additions and 970 deletions
@ -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<ExceptionHandlingResource>(name); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -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"; |
|
||||
} |
|
||||
} |
|
||||
@ -1,29 +1,12 @@ |
|||||
using LINGYUN.Abp.ExceptionHandling.Localization; |
using LINGYUN.Abp.Notifications.Common; |
||||
using LINGYUN.Abp.Notifications; |
|
||||
using Volo.Abp.Localization; |
|
||||
using Volo.Abp.Modularity; |
using Volo.Abp.Modularity; |
||||
using Volo.Abp.VirtualFileSystem; |
|
||||
|
|
||||
namespace LINGYUN.Abp.ExceptionHandling.Notifications |
namespace LINGYUN.Abp.ExceptionHandling.Notifications |
||||
{ |
{ |
||||
[DependsOn( |
[DependsOn( |
||||
typeof(AbpExceptionHandlingModule), |
typeof(AbpExceptionHandlingModule), |
||||
typeof(AbpNotificationModule))] |
typeof(AbpNotificationsCommonModule))] |
||||
public class AbpNotificationsExceptionHandlingModule : AbpModule |
public class AbpNotificationsExceptionHandlingModule : AbpModule |
||||
{ |
{ |
||||
public override void ConfigureServices(ServiceConfigurationContext context) |
|
||||
{ |
|
||||
Configure<AbpVirtualFileSystemOptions>(options => |
|
||||
{ |
|
||||
options.FileSets.AddEmbedded<AbpNotificationsExceptionHandlingModule>(); |
|
||||
}); |
|
||||
|
|
||||
Configure<AbpLocalizationOptions>(options => |
|
||||
{ |
|
||||
options.Resources |
|
||||
.Get<ExceptionHandlingResource>() |
|
||||
.AddVirtualJson("/LINGYUN/Abp/ExceptionHandling/Notifications/Localization/Resources"); |
|
||||
}); |
|
||||
} |
|
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -1,7 +0,0 @@ |
|||||
{ |
|
||||
"culture": "en", |
|
||||
"texts": { |
|
||||
"Notifications:Exception": "Exception", |
|
||||
"Notifications:ExceptionNotifier": "Exception Notifier" |
|
||||
} |
|
||||
} |
|
||||
@ -1,7 +0,0 @@ |
|||||
{ |
|
||||
"culture": "zh-Hans", |
|
||||
"texts": { |
|
||||
"Notifications:Exception": "异常通知", |
|
||||
"Notifications:ExceptionNotifier": "异常推送" |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,30 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
||||
|
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
||||
|
<xs:element name="Weavers"> |
||||
|
<xs:complexType> |
||||
|
<xs:all> |
||||
|
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
||||
|
<xs:complexType> |
||||
|
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:all> |
||||
|
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:schema> |
||||
@ -0,0 +1,31 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\..\configureawait.props" /> |
||||
|
<Import Project="..\..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netstandard2.0</TargetFramework> |
||||
|
<RootNamespace /> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<None Remove="LINGYUN\Abp\Notifications\Emailing\Templates\ExceptionNotifier\*.tpl" /> |
||||
|
<None Remove="LINGYUN\Abp\Notifications\Emailing\Templates\layout.tpl" /> |
||||
|
<None Remove="LINGYUN\Abp\Notifications\Emailing\Templates\NewTenantRegisterd\*.tpl" /> |
||||
|
<None Remove="LINGYUN\Abp\Notifications\Emailing\Templates\WelcomeToApplication\*.tpl" /> |
||||
|
<None Remove="LINGYUN\Abp\Notifications\Localization\Common\*.json" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<EmbeddedResource Include="LINGYUN\Abp\Notifications\Emailing\Templates\ExceptionNotifier\*.tpl" /> |
||||
|
<EmbeddedResource Include="LINGYUN\Abp\Notifications\Emailing\Templates\layout.tpl" /> |
||||
|
<EmbeddedResource Include="LINGYUN\Abp\Notifications\Emailing\Templates\NewTenantRegisterd\*.tpl" /> |
||||
|
<EmbeddedResource Include="LINGYUN\Abp\Notifications\Emailing\Templates\WelcomeToApplication\*.tpl" /> |
||||
|
<EmbeddedResource Include="LINGYUN\Abp\Notifications\Localization\Common\*.json" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\LINGYUN.Abp.Notifications\LINGYUN.Abp.Notifications.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -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<AbpVirtualFileSystemOptions>(options => |
||||
|
{ |
||||
|
options.FileSets.AddEmbedded<AbpNotificationsCommonModule>(); |
||||
|
}); |
||||
|
|
||||
|
Configure<AbpLocalizationOptions>(options => |
||||
|
{ |
||||
|
options.Resources |
||||
|
.Get<NotificationsResource>() |
||||
|
.AddVirtualJson("/LINGYUN/Abp/Notifications/Localization/Common"); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -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) |
||||
|
}; |
||||
|
} |
||||
|
} |
||||
@ -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" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
{ |
||||
|
"culture": "zh-Hans", |
||||
|
"texts": { |
||||
|
"Notifications:MultiTenancy": "租户通知", |
||||
|
"Notifications:Users": "用户通知", |
||||
|
"Notifications:NewTenantRegisterd": "租户创建通知", |
||||
|
"Notifications:WelcomeToApplication": "用户欢迎通知", |
||||
|
"Notifications:Primitives": "标准通知", |
||||
|
"Notifications:ExceptionNotifier": "异常通知推送" |
||||
|
} |
||||
|
} |
||||
@ -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<NotificationsResource>(name); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
namespace LINGYUN.Abp.Notifications |
||||
|
{ |
||||
|
public class NotificationsCommonNotificationNames |
||||
|
{ |
||||
|
public const string GroupName = "LINGYUN.Abp.Notifications.Primitives"; |
||||
|
/// <summary>
|
||||
|
/// 异常处理
|
||||
|
/// </summary>
|
||||
|
public const string ExceptionHandling = GroupName + ".ExceptionHandling"; |
||||
|
} |
||||
|
} |
||||
@ -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 |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
@ -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<string> GetOrNullAsync(TemplateContentContributorContext context) |
|
||||
{ |
|
||||
var store = context.ServiceProvider.GetRequiredService<INotificationTemplateStore>(); |
|
||||
|
|
||||
return await store.GetOrNullAsync(context.TemplateDefinition.Name, context.Culture); |
|
||||
} |
|
||||
} |
|
||||
@ -1,30 +1,31 @@ |
|||||
<Project Sdk="Microsoft.NET.Sdk"> |
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
<Import Project="..\..\..\configureawait.props" /> |
<Import Project="..\..\..\configureawait.props" /> |
||||
<Import Project="..\..\..\common.props" /> |
<Import Project="..\..\..\common.props" /> |
||||
|
|
||||
<PropertyGroup> |
<PropertyGroup> |
||||
<TargetFramework>netstandard2.0</TargetFramework> |
<TargetFramework>netstandard2.0</TargetFramework> |
||||
<RootNamespace /> |
<RootNamespace /> |
||||
</PropertyGroup> |
</PropertyGroup> |
||||
|
|
||||
<ItemGroup> |
<ItemGroup> |
||||
<None Remove="LINGYUN\Abp\Notifications\Localization\Resources\*.json" /> |
<None Remove="LINGYUN\Abp\Notifications\Localization\Resources\*.json" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
|
|
||||
<ItemGroup> |
<ItemGroup> |
||||
<EmbeddedResource Include="LINGYUN\Abp\Notifications\Localization\Resources\*.json" /> |
<EmbeddedResource Include="LINGYUN\Abp\Notifications\Localization\Resources\*.json" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
|
|
||||
<ItemGroup> |
<ItemGroup> |
||||
<PackageReference Include="Volo.Abp.EventBus" Version="$(VoloAbpPackageVersion)" /> |
<PackageReference Include="Volo.Abp.EventBus" Version="$(VoloAbpPackageVersion)" /> |
||||
<PackageReference Include="Volo.Abp.Json" Version="$(VoloAbpPackageVersion)" /> |
<PackageReference Include="Volo.Abp.Json" Version="$(VoloAbpPackageVersion)" /> |
||||
<PackageReference Include="Volo.Abp.BackgroundJobs.Abstractions" Version="$(VoloAbpPackageVersion)" /> |
<PackageReference Include="Volo.Abp.BackgroundJobs.Abstractions" Version="$(VoloAbpPackageVersion)" /> |
||||
</ItemGroup> |
<PackageReference Include="Volo.Abp.TextTemplating.Core" Version="$(VoloAbpPackageVersion)" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
<ItemGroup> |
<ItemGroup> |
||||
<ProjectReference Include="..\LINGYUN.Abp.IdGenerator\LINGYUN.Abp.IdGenerator.csproj" /> |
<ProjectReference Include="..\LINGYUN.Abp.IdGenerator\LINGYUN.Abp.IdGenerator.csproj" /> |
||||
<ProjectReference Include="..\LINGYUN.Abp.RealTime\LINGYUN.Abp.RealTime.csproj" /> |
<ProjectReference Include="..\LINGYUN.Abp.RealTime\LINGYUN.Abp.RealTime.csproj" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
|
|
||||
</Project> |
</Project> |
||||
|
|||||
@ -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); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,9 +0,0 @@ |
|||||
using System.Threading; |
|
||||
using System.Threading.Tasks; |
|
||||
|
|
||||
namespace LINGYUN.Abp.Notifications; |
|
||||
|
|
||||
public interface INotificationTemplateStore |
|
||||
{ |
|
||||
Task<string> GetOrNullAsync(string templateName, string culture = null, CancellationToken cancellationToken = default); |
|
||||
} |
|
||||
@ -1,12 +1,24 @@ |
|||||
{ |
{ |
||||
"culture": "en", |
"culture": "en", |
||||
"texts": { |
"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:Internal": "Internal", |
||||
"Notifications:OnsideNotice": "Onside", |
"Notifications:OnsideNotice": "Onside", |
||||
"Notifications:OnsideNoticeDesc": "In-app notification push", |
"Notifications:OnsideNoticeDesc": "In-app notification push", |
||||
"Notifications:ActivityNotice": "Activity", |
"Notifications:ActivityNotice": "Activity", |
||||
"Notifications:ActivityNoticeDesc": "The administrator delivers an event notification push", |
"Notifications:ActivityNoticeDesc": "The administrator delivers an event notification push", |
||||
"Notifications:SystemNotice": "System", |
"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" |
||||
} |
} |
||||
} |
} |
||||
@ -1,12 +1,24 @@ |
|||||
{ |
{ |
||||
"culture": "zh-Hans", |
"culture": "zh-Hans", |
||||
"texts": { |
"texts": { |
||||
|
"Notifications": "通知列表", |
||||
|
"Notifications:Title": "标题", |
||||
|
"Notifications:Content": "内容", |
||||
|
"Notifications:Type": "类型", |
||||
|
"Notifications:SendTime": "发送时间", |
||||
|
"Notifications:System": "系统", |
||||
|
"Notifications:Application": "平台", |
||||
|
"Notifications:User": "用户", |
||||
"Notifications:Internal": "内置通知", |
"Notifications:Internal": "内置通知", |
||||
"Notifications:OnsideNotice": "站内通知", |
"Notifications:OnsideNotice": "站内通知", |
||||
"Notifications:OnsideNoticeDesc": "应用内部通知推送", |
"Notifications:OnsideNoticeDesc": "应用内部通知推送", |
||||
"Notifications:ActivityNotice": "活动通知", |
"Notifications:ActivityNotice": "活动通知", |
||||
"Notifications:ActivityNoticeDesc": "管理员下发活动通知推送", |
"Notifications:ActivityNoticeDesc": "管理员下发活动通知推送", |
||||
"Notifications:SystemNotice": "系统通知", |
"Notifications:SystemNotice": "系统通知", |
||||
"Notifications:SystemNoticeDesc": "系统全局消息推送" |
"Notifications:SystemNoticeDesc": "系统全局消息推送", |
||||
|
"MarkSelectedAsRead": "标记选中已读", |
||||
|
"MarkAs": "标记为", |
||||
|
"Read": "已读", |
||||
|
"UnRead": "未读" |
||||
} |
} |
||||
} |
} |
||||
@ -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<string> GetOrNullAsync(string templateName, string culture = null, CancellationToken cancellationToken = default) |
|
||||
{ |
|
||||
return Task.FromResult<string>(null); |
|
||||
} |
|
||||
} |
|
||||
@ -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; } |
||||
|
} |
||||
@ -1,9 +1,12 @@ |
|||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
|
||||
namespace LINGYUN.Abp.MessageService.Notifications |
namespace LINGYUN.Abp.MessageService.Notifications |
||||
{ |
{ |
||||
public interface INotificationAppService |
public interface INotificationAppService |
||||
{ |
{ |
||||
|
Task<ListResultDto<NotificationTemplateDto>> GetAssignableTemplatesAsync(); |
||||
|
|
||||
Task SendAsync(NotificationSendDto input); |
Task SendAsync(NotificationSendDto input); |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -1,35 +1,88 @@ |
|||||
using LINGYUN.Abp.Notifications; |
using LINGYUN.Abp.Notifications; |
||||
using Microsoft.AspNetCore.Authorization; |
using Microsoft.AspNetCore.Authorization; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Globalization; |
||||
|
using System.Linq; |
||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
using Volo.Abp.Application.Services; |
using Volo.Abp.Application.Services; |
||||
|
using Volo.Abp.TextTemplating; |
||||
|
|
||||
namespace LINGYUN.Abp.MessageService.Notifications |
namespace LINGYUN.Abp.MessageService.Notifications |
||||
{ |
{ |
||||
[Authorize] |
[Authorize] |
||||
public class NotificationAppService : ApplicationService, INotificationAppService |
public class NotificationAppService : ApplicationService, INotificationAppService |
||||
{ |
{ |
||||
|
protected ITemplateContentProvider TemplateContentProvider { get; } |
||||
protected INotificationSender NotificationSender { get; } |
protected INotificationSender NotificationSender { get; } |
||||
|
protected INotificationDefinitionManager NotificationDefinitionManager { get; } |
||||
|
|
||||
public NotificationAppService( |
public NotificationAppService( |
||||
INotificationSender notificationSender) |
INotificationSender notificationSender, |
||||
|
ITemplateContentProvider templateContentProvider, |
||||
|
INotificationDefinitionManager notificationDefinitionManager) |
||||
{ |
{ |
||||
NotificationSender = notificationSender; |
NotificationSender = notificationSender; |
||||
|
TemplateContentProvider = templateContentProvider; |
||||
|
NotificationDefinitionManager = notificationDefinitionManager; |
||||
|
} |
||||
|
|
||||
|
public virtual Task<ListResultDto<NotificationTemplateDto>> GetAssignableTemplatesAsync() |
||||
|
{ |
||||
|
var templates = new List<NotificationTemplateDto>(); |
||||
|
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<NotificationTemplateDto>(templates)); |
||||
} |
} |
||||
|
|
||||
public virtual async Task SendAsync(NotificationSendDto input) |
public async virtual Task SendAsync(NotificationSendDto input) |
||||
{ |
{ |
||||
|
var notification = GetNotificationDefinition(input.Name); |
||||
|
|
||||
UserIdentifier user = null; |
UserIdentifier user = null; |
||||
if (input.ToUserId.HasValue) |
if (input.ToUserId.HasValue) |
||||
{ |
{ |
||||
user = new UserIdentifier(input.ToUserId.Value, input.ToUserName); |
user = new UserIdentifier(input.ToUserId.Value, input.ToUserName); |
||||
} |
} |
||||
|
|
||||
await NotificationSender |
await NotificationSender |
||||
.SendNofiterAsync( |
.SendNofiterAsync( |
||||
input.Name, |
name: input.Name, |
||||
input.Data, |
template: new NotificationTemplate( |
||||
user, |
notification.Name, |
||||
|
culture: input.Culture ?? CultureInfo.CurrentCulture.Name, |
||||
|
formUser: CurrentUser.Name ?? CurrentUser.UserName, |
||||
|
data: input.Data), |
||||
|
user: user, |
||||
CurrentTenant.Id, |
CurrentTenant.Id, |
||||
input.Severity); |
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; |
||||
|
} |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -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; |
||||
|
} |
||||
@ -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<Guid> |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
@ -0,0 +1,3 @@ |
|||||
|
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
||||
|
<ConfigureAwait ContinueOnCapturedContext="false" /> |
||||
|
</Weavers> |
||||
@ -0,0 +1,30 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
||||
|
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
||||
|
<xs:element name="Weavers"> |
||||
|
<xs:complexType> |
||||
|
<xs:all> |
||||
|
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
||||
|
<xs:complexType> |
||||
|
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:all> |
||||
|
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:schema> |
||||
@ -0,0 +1,24 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netstandard2.0</TargetFramework> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<Import Project="..\..\..\configureawait.props" /> |
||||
|
<Import Project="..\..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netstandard2.0</TargetFramework> |
||||
|
<RootNamespace /> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Volo.Abp.Authorization.Abstractions" Version="$(VoloAbpPackageVersion)" /> |
||||
|
<PackageReference Include="Volo.Abp.Ddd.Application.Contracts" Version="$(VoloAbpPackageVersion)" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\LINGYUN.Abp.TextTemplating.Domain.Shared\LINGYUN.Abp.TextTemplating.Domain.Shared.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -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 |
||||
|
{ |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
namespace LINGYUN.Abp.TextTemplating; |
||||
|
|
||||
|
public class AbpTextTemplatingRemoteServiceConsts |
||||
|
{ |
||||
|
public const string RemoteServiceName = "AbpTextTemplating"; |
||||
|
|
||||
|
public const string ModuleName = "text-templating"; |
||||
|
} |
||||
@ -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<TextTemplateDto> GetAsync(TextTemplateGetInput input); |
||||
|
|
||||
|
Task ResetDefaultAsync(TextTemplateGetInput input); |
||||
|
|
||||
|
Task<TextTemplateDto> UpdateAsync(TextTemplateUpdateInput input); |
||||
|
|
||||
|
Task<ListResultDto<TextTemplateDto>> GetListAsync(); |
||||
|
} |
||||
@ -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<AbpTextTemplatingResource>(name); |
||||
|
} |
||||
|
} |
||||
@ -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)); |
||||
|
} |
||||
|
} |
||||
@ -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; } |
||||
|
} |
||||
@ -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; } |
||||
|
} |
||||
@ -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; } |
||||
|
} |
||||
@ -0,0 +1,3 @@ |
|||||
|
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
||||
|
<ConfigureAwait ContinueOnCapturedContext="false" /> |
||||
|
</Weavers> |
||||
@ -0,0 +1,30 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
||||
|
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
||||
|
<xs:element name="Weavers"> |
||||
|
<xs:complexType> |
||||
|
<xs:all> |
||||
|
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
||||
|
<xs:complexType> |
||||
|
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:all> |
||||
|
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:schema> |
||||
@ -0,0 +1,21 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\..\configureawait.props" /> |
||||
|
<Import Project="..\..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netstandard2.1</TargetFramework> |
||||
|
<RootNamespace /> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Volo.Abp.Ddd.Application" Version="$(VoloAbpPackageVersion)" /> |
||||
|
<PackageReference Include="Volo.Abp.AutoMapper" Version="$(VoloAbpPackageVersion)" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\LINGYUN.Abp.TextTemplating.Application.Contracts\LINGYUN.Abp.TextTemplating.Application.Contracts.csproj" /> |
||||
|
<ProjectReference Include="..\LINGYUN.Abp.TextTemplating.Domain\LINGYUN.Abp.TextTemplating.Domain.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -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); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
using AutoMapper; |
||||
|
|
||||
|
namespace LINGYUN.Abp.TextTemplating; |
||||
|
|
||||
|
public class AbpTextTemplatingApplicationAutoMapperProfile : Profile |
||||
|
{ |
||||
|
public AbpTextTemplatingApplicationAutoMapperProfile() |
||||
|
{ |
||||
|
CreateMap<TextTemplate, TextTemplateDto>(); |
||||
|
} |
||||
|
} |
||||
@ -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<AbpTextTemplatingApplicationModule>(); |
||||
|
Configure<AbpAutoMapperOptions>(options => |
||||
|
{ |
||||
|
options.AddProfile<AbpTextTemplatingApplicationAutoMapperProfile>(validate: true); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -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<TextTemplateDto> 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<ListResultDto<TextTemplateDto>> GetListAsync() |
||||
|
{ |
||||
|
var templates = new List<TextTemplateDto>(); |
||||
|
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<TextTemplateDto>(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<TextTemplateDto> 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<TextTemplate, TextTemplateDto>(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; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,3 @@ |
|||||
|
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
||||
|
<ConfigureAwait ContinueOnCapturedContext="false" /> |
||||
|
</Weavers> |
||||
@ -0,0 +1,30 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
||||
|
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
||||
|
<xs:element name="Weavers"> |
||||
|
<xs:complexType> |
||||
|
<xs:all> |
||||
|
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
||||
|
<xs:complexType> |
||||
|
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:all> |
||||
|
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:schema> |
||||
@ -0,0 +1,20 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\..\configureawait.props" /> |
||||
|
<Import Project="..\..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netstandard2.0</TargetFramework> |
||||
|
<RootNamespace /> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<None Remove="LINGYUN\Abp\TextTemplating\Localization\Resources\*.json" /> |
||||
|
<EmbeddedResource Include="LINGYUN\Abp\TextTemplating\Localization\Resources\*.json" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Volo.Abp.Validation" Version="$(VoloAbpPackageVersion)" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -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<AbpVirtualFileSystemOptions>(options => |
||||
|
{ |
||||
|
options.FileSets.AddEmbedded<AbpTextTemplatingDomainSharedModule>(); |
||||
|
}); |
||||
|
|
||||
|
Configure<AbpLocalizationOptions>(options => |
||||
|
{ |
||||
|
options.Resources |
||||
|
.Add<AbpTextTemplatingResource>("en") |
||||
|
.AddVirtualJson("/LINGYUN/Abp/TextTemplating/Localization/Resources"); |
||||
|
}); |
||||
|
|
||||
|
Configure<AbpExceptionLocalizationOptions>(options => |
||||
|
{ |
||||
|
options.MapCodeNamespace(AbpTextTemplatingErrorCodes.Namespace, typeof(AbpTextTemplatingResource)); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
namespace LINGYUN.Abp.TextTemplating; |
||||
|
|
||||
|
public static class AbpTextTemplatingErrorCodes |
||||
|
{ |
||||
|
public const string Namespace = "TextTemplating"; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 模板不存在!
|
||||
|
/// </summary>
|
||||
|
public const string TemplateNotFound = Namespace + ":01404"; |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
using Volo.Abp.Localization; |
||||
|
|
||||
|
namespace LINGYUN.Abp.TextTemplating.Localization; |
||||
|
|
||||
|
[LocalizationResourceName("AbpTextTemplating")] |
||||
|
public class AbpTextTemplatingResource |
||||
|
{ |
||||
|
} |
||||
@ -0,0 +1,5 @@ |
|||||
|
{ |
||||
|
"culture": "en", |
||||
|
"texts": { |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,5 @@ |
|||||
|
{ |
||||
|
"culture": "zh-Hans", |
||||
|
"texts": { |
||||
|
} |
||||
|
} |
||||
@ -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; |
||||
|
} |
||||
@ -0,0 +1,3 @@ |
|||||
|
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
||||
|
<ConfigureAwait ContinueOnCapturedContext="false" /> |
||||
|
</Weavers> |
||||
@ -0,0 +1,30 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
||||
|
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
||||
|
<xs:element name="Weavers"> |
||||
|
<xs:complexType> |
||||
|
<xs:all> |
||||
|
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
||||
|
<xs:complexType> |
||||
|
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:all> |
||||
|
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:schema> |
||||
@ -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"; |
||||
|
} |
||||
@ -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 |
||||
|
{ |
||||
|
|
||||
|
} |
||||
@ -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<TextTemplate, Guid> |
||||
|
{ |
||||
|
Task<TextTemplate> FindByNameAsync(string name, string culture = null, CancellationToken cancellationToken = default); |
||||
|
} |
||||
@ -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<Guid>, 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); |
||||
|
} |
||||
|
} |
||||
@ -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<string> GetOrNullAsync(TemplateContentContributorContext context) |
||||
|
{ |
||||
|
var repository = context.ServiceProvider.GetRequiredService<ITextTemplateRepository>(); |
||||
|
var template = await repository.FindByNameAsync(context.TemplateDefinition.Name, context.Culture); |
||||
|
|
||||
|
return template?.Content; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,3 @@ |
|||||
|
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
||||
|
<ConfigureAwait ContinueOnCapturedContext="false" /> |
||||
|
</Weavers> |
||||
@ -0,0 +1,30 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
||||
|
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
||||
|
<xs:element name="Weavers"> |
||||
|
<xs:complexType> |
||||
|
<xs:all> |
||||
|
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
||||
|
<xs:complexType> |
||||
|
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:all> |
||||
|
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:schema> |
||||
@ -0,0 +1,19 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\..\configureawait.props" /> |
||||
|
<Import Project="..\..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>net6.0</TargetFramework> |
||||
|
<RootNamespace /> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Volo.Abp.EntityFrameworkCore" Version="$(VoloAbpPackageVersion)" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\LINGYUN.Abp.TextTemplating.Domain\LINGYUN.Abp.TextTemplating.Domain.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -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<TextTemplate>(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<TextTemplatingDbContext>(); |
||||
|
} |
||||
|
} |
||||
@ -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<TextTemplatingDbContext>(options => |
||||
|
{ |
||||
|
options.AddRepository<TextTemplate, EfCoreTextTemplateRepository>(); |
||||
|
|
||||
|
options.AddDefaultRepositories<ITextTemplatingDbContext>(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -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<ITextTemplatingDbContext, TextTemplate, Guid>, |
||||
|
ITextTemplateRepository, |
||||
|
ITransientDependency |
||||
|
{ |
||||
|
public EfCoreTextTemplateRepository( |
||||
|
IDbContextProvider<ITextTemplatingDbContext> dbContextProvider) |
||||
|
: base(dbContextProvider) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public async virtual Task<TextTemplate> 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)); |
||||
|
} |
||||
|
} |
||||
@ -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<TextTemplate> TextTemplates { get; } |
||||
|
} |
||||
@ -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<TextTemplatingDbContext>, ITextTemplatingDbContext |
||||
|
{ |
||||
|
public DbSet<TextTemplate> TextTemplates { get; set; } |
||||
|
|
||||
|
public TextTemplatingDbContext(DbContextOptions<TextTemplatingDbContext> options) |
||||
|
: base(options) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
protected override void OnModelCreating(ModelBuilder builder) |
||||
|
{ |
||||
|
base.OnModelCreating(builder); |
||||
|
|
||||
|
builder.ConfigureTextTemplating(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,5 @@ |
|||||
|
namespace LINGYUN.Abp.TextTemplating.EntityFrameworkCore; |
||||
|
|
||||
|
public static class TextTemplatingEfCoreQueryableExtensions |
||||
|
{ |
||||
|
} |
||||
@ -0,0 +1,3 @@ |
|||||
|
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
||||
|
<ConfigureAwait ContinueOnCapturedContext="false" /> |
||||
|
</Weavers> |
||||
@ -0,0 +1,30 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
||||
|
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
||||
|
<xs:element name="Weavers"> |
||||
|
<xs:complexType> |
||||
|
<xs:all> |
||||
|
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
||||
|
<xs:complexType> |
||||
|
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:all> |
||||
|
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:schema> |
||||
@ -0,0 +1,19 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\..\configureawait.props" /> |
||||
|
<Import Project="..\..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netstandard2.0</TargetFramework> |
||||
|
<RootNamespace /> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Volo.Abp.Http.Client" Version="$(VoloAbpPackageVersion)" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\LINGYUN.Abp.TextTemplating.Application.Contracts\LINGYUN.Abp.TextTemplating.Application.Contracts.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -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 |
||||
|
); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,3 @@ |
|||||
|
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
||||
|
<ConfigureAwait ContinueOnCapturedContext="false" /> |
||||
|
</Weavers> |
||||
@ -0,0 +1,30 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
||||
|
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
||||
|
<xs:element name="Weavers"> |
||||
|
<xs:complexType> |
||||
|
<xs:all> |
||||
|
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
||||
|
<xs:complexType> |
||||
|
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:all> |
||||
|
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:schema> |
||||
@ -0,0 +1,19 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\..\configureawait.props" /> |
||||
|
<Import Project="..\..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>net6.0</TargetFramework> |
||||
|
<RootNamespace /> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Volo.Abp.AspNetCore.Mvc" Version="$(VoloAbpPackageVersion)" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\LINGYUN.Abp.TextTemplating.Application.Contracts\LINGYUN.Abp.TextTemplating.Application.Contracts.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -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); |
||||
|
} |
||||
|
} |
||||
@ -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<IMvcBuilder>(mvcBuilder => |
||||
|
{ |
||||
|
mvcBuilder.AddApplicationPartIfNotExists(typeof(AbpTextTemplatingHttpApiModule).Assembly); |
||||
|
}); |
||||
|
|
||||
|
PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options => |
||||
|
{ |
||||
|
options.AddAssemblyResource( |
||||
|
typeof(AbpTextTemplatingResource), |
||||
|
typeof(AbpTextTemplatingApplicationContractsModule).Assembly); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
Configure<AbpLocalizationOptions>(options => |
||||
|
{ |
||||
|
options.Resources |
||||
|
.Get<AbpTextTemplatingResource>() |
||||
|
.AddBaseTypes(typeof(AbpUiResource)); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -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<TextTemplateDto> GetAsync(TextTemplateGetInput input) |
||||
|
{ |
||||
|
return TextTemplateAppService.GetAsync(input); |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
public Task<ListResultDto<TextTemplateDto>> 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<TextTemplateDto> UpdateAsync(TextTemplateUpdateInput input) |
||||
|
{ |
||||
|
return TextTemplateAppService.UpdateAsync(input); |
||||
|
} |
||||
|
} |
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue