118 changed files with 1844 additions and 1384 deletions
@ -1,36 +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) |
|||
// 设定为模板通知
|
|||
.WithTemplate(typeof(ExceptionHandlingResource)); |
|||
} |
|||
|
|||
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; |
|||
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<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,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,23 +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 notificationDefinitionManager = context.ServiceProvider.GetRequiredService<INotificationDefinitionManager>(); |
|||
var notification = notificationDefinitionManager.GetOrNull(context.TemplateDefinition.Name); |
|||
if (notification == null) |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
var store = context.ServiceProvider.GetRequiredService<INotificationTemplateStore>(); |
|||
|
|||
return await store.GetContentOrNullAsync(context.TemplateDefinition.Name, context.Culture); |
|||
} |
|||
} |
|||
@ -1,9 +0,0 @@ |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace LINGYUN.Abp.Notifications; |
|||
|
|||
public interface INotificationTemplateStore |
|||
{ |
|||
Task<string> GetContentOrNullAsync(string templateName, string culture = null, CancellationToken cancellationToken = default); |
|||
} |
|||
@ -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" |
|||
} |
|||
} |
|||
@ -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": "未读" |
|||
} |
|||
} |
|||
@ -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> GetContentOrNullAsync(string templateName, string culture = null, CancellationToken cancellationToken = default) |
|||
{ |
|||
return Task.FromResult<string>(null); |
|||
} |
|||
} |
|||
@ -1,11 +0,0 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace LINGYUN.Abp.MessageService.Notifications; |
|||
|
|||
public class NotificationTemplateGetInput |
|||
{ |
|||
[Required] |
|||
public string Name { get; set; } |
|||
|
|||
public string Culture { get; set; } |
|||
} |
|||
@ -1,19 +0,0 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.Validation; |
|||
|
|||
namespace LINGYUN.Abp.MessageService.Notifications; |
|||
|
|||
public class NotificationTemplateSetInput |
|||
{ |
|||
[Required] |
|||
[DynamicStringLength(typeof(NotificationTemplateConsts), nameof(NotificationTemplateConsts.MaxNameLength))] |
|||
public string Name { get; set; } |
|||
|
|||
[Required] |
|||
[DynamicStringLength(typeof(NotificationTemplateConsts), nameof(NotificationTemplateConsts.MaxCultureLength))] |
|||
public string Culture { get; set; } |
|||
|
|||
[Required] |
|||
[DynamicStringLength(typeof(NotificationTemplateConsts), nameof(NotificationTemplateConsts.MaxContentLength))] |
|||
public string Content { get; set; } |
|||
} |
|||
@ -1,11 +0,0 @@ |
|||
using System; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Repositories; |
|||
|
|||
namespace LINGYUN.Abp.MessageService.Notifications; |
|||
|
|||
public interface INotificationTemplateRepository : IBasicRepository<NotificationTemplate, Guid> |
|||
{ |
|||
Task<NotificationTemplate> GetByNameAsync(string name, string culture = null, CancellationToken cancellationToken = default); |
|||
} |
|||
@ -1,37 +0,0 @@ |
|||
using System; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Domain.Entities.Auditing; |
|||
using Volo.Abp.MultiTenancy; |
|||
|
|||
namespace LINGYUN.Abp.MessageService.Notifications; |
|||
|
|||
public class NotificationTemplate : AuditedEntity<Guid>, IMultiTenant |
|||
{ |
|||
public virtual Guid? TenantId { get; protected set; } |
|||
public virtual string Name { get; private set; } |
|||
public virtual string Description { get; private set; } |
|||
public virtual string Title { get; private set; } |
|||
public virtual string Content { get; private set; } |
|||
public virtual string Culture { get; private set; } |
|||
protected NotificationTemplate() { } |
|||
public NotificationTemplate( |
|||
Guid id, |
|||
string name, |
|||
string title, |
|||
string content, |
|||
string culture, |
|||
string description = null) |
|||
: base(id) |
|||
{ |
|||
Name = Check.NotNullOrWhiteSpace(name, nameof(name), NotificationTemplateConsts.MaxNameLength); |
|||
Title = Check.NotNullOrWhiteSpace(title, nameof(title), NotificationTemplateConsts.MaxTitleLength); |
|||
Content = Check.NotNullOrWhiteSpace(content, nameof(content), NotificationTemplateConsts.MaxContentLength); |
|||
Culture = Check.NotNullOrWhiteSpace(culture, nameof(culture), NotificationTemplateConsts.MaxCultureLength); |
|||
Description = Check.Length(description, nameof(description), NotificationTemplateConsts.MaxDescriptionLength); |
|||
} |
|||
|
|||
public void SetContent(string content) |
|||
{ |
|||
Content = Check.NotNullOrWhiteSpace(content, nameof(content), NotificationTemplateConsts.MaxContentLength); |
|||
} |
|||
} |
|||
@ -1,31 +0,0 @@ |
|||
using LINGYUN.Abp.Notifications; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using System.Globalization; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace LINGYUN.Abp.MessageService.Notifications; |
|||
|
|||
[Dependency(ServiceLifetime.Transient, ReplaceServices = true)] |
|||
[ExposeServices(typeof(INotificationTemplateStore))] |
|||
public class NotificationTemplateStore : INotificationTemplateStore |
|||
{ |
|||
protected INotificationTemplateRepository NotificationTemplateRepository { get; } |
|||
|
|||
public NotificationTemplateStore( |
|||
INotificationTemplateRepository notificationTemplateRepository) |
|||
{ |
|||
NotificationTemplateRepository = notificationTemplateRepository; |
|||
} |
|||
|
|||
public async virtual Task<string> GetContentOrNullAsync(string templateName, string culture = null, CancellationToken cancellationToken = default) |
|||
{ |
|||
var template = await NotificationTemplateRepository.GetByNameAsync( |
|||
templateName, |
|||
culture ?? CultureInfo.CurrentCulture.Name, |
|||
cancellationToken); |
|||
|
|||
return template?.Content; |
|||
} |
|||
} |
|||
@ -1,32 +0,0 @@ |
|||
using LINGYUN.Abp.MessageService.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
namespace LINGYUN.Abp.MessageService.Notifications; |
|||
|
|||
public class EfCoreNotificationTemplateRepository : |
|||
EfCoreRepository<IMessageServiceDbContext, NotificationTemplate, Guid>, |
|||
INotificationTemplateRepository, |
|||
ITransientDependency |
|||
{ |
|||
public EfCoreNotificationTemplateRepository( |
|||
IDbContextProvider<IMessageServiceDbContext> dbContextProvider) |
|||
: base(dbContextProvider) |
|||
{ |
|||
} |
|||
|
|||
public async virtual Task<NotificationTemplate> GetByNameAsync(string name, string culture = null, CancellationToken cancellationToken = default) |
|||
{ |
|||
return await (await GetDbSetAsync()) |
|||
.Where(x => x.Name.Equals(name)) |
|||
.WhereIf(!culture.IsNullOrWhiteSpace(), x => x.Culture.Equals(culture)) |
|||
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); |
|||
} |
|||
} |
|||
@ -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); |
|||
} |
|||
} |
|||
@ -0,0 +1,354 @@ |
|||
// <auto-generated />
|
|||
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<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasMaxLength(40) |
|||
.HasColumnType("varchar(40)") |
|||
.HasColumnName("ConcurrencyStamp"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("CreationTime"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("CreatorId"); |
|||
|
|||
b.Property<Guid?>("DeleterId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("DeleterId"); |
|||
|
|||
b.Property<DateTime?>("DeletionTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("DeletionTime"); |
|||
|
|||
b.Property<string>("DisplayName") |
|||
.IsRequired() |
|||
.HasMaxLength(64) |
|||
.HasColumnType("varchar(64)"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnType("longtext") |
|||
.HasColumnName("ExtraProperties"); |
|||
|
|||
b.Property<bool>("IsDeleted") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("tinyint(1)") |
|||
.HasDefaultValue(false) |
|||
.HasColumnName("IsDeleted"); |
|||
|
|||
b.Property<DateTime?>("LastModificationTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("LastModificationTime"); |
|||
|
|||
b.Property<Guid?>("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<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasMaxLength(40) |
|||
.HasColumnType("varchar(40)") |
|||
.HasColumnName("ConcurrencyStamp"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("CreationTime"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("CreatorId"); |
|||
|
|||
b.Property<Guid?>("DeleterId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("DeleterId"); |
|||
|
|||
b.Property<DateTime?>("DeletionTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("DeletionTime"); |
|||
|
|||
b.Property<DateTime?>("DisableTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid?>("EditionId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<DateTime?>("EnableTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnType("longtext") |
|||
.HasColumnName("ExtraProperties"); |
|||
|
|||
b.Property<bool>("IsActive") |
|||
.HasColumnType("tinyint(1)"); |
|||
|
|||
b.Property<bool>("IsDeleted") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("tinyint(1)") |
|||
.HasDefaultValue(false) |
|||
.HasColumnName("IsDeleted"); |
|||
|
|||
b.Property<DateTime?>("LastModificationTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("LastModificationTime"); |
|||
|
|||
b.Property<Guid?>("LastModifierId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("LastModifierId"); |
|||
|
|||
b.Property<string>("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<Guid>("TenantId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("Name") |
|||
.HasMaxLength(64) |
|||
.HasColumnType("varchar(64)"); |
|||
|
|||
b.Property<string>("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<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("Content") |
|||
.HasMaxLength(1048576) |
|||
.HasColumnType("longtext") |
|||
.HasColumnName("Content"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("CreationTime"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("CreatorId"); |
|||
|
|||
b.Property<string>("Culture") |
|||
.IsRequired() |
|||
.HasMaxLength(30) |
|||
.HasColumnType("varchar(30)") |
|||
.HasColumnName("Culture"); |
|||
|
|||
b.Property<string>("DisplayName") |
|||
.IsRequired() |
|||
.HasMaxLength(100) |
|||
.HasColumnType("varchar(100)") |
|||
.HasColumnName("DisplayName"); |
|||
|
|||
b.Property<DateTime?>("LastModificationTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("LastModificationTime"); |
|||
|
|||
b.Property<Guid?>("LastModifierId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("LastModifierId"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasMaxLength(100) |
|||
.HasColumnType("varchar(100)") |
|||
.HasColumnName("Name"); |
|||
|
|||
b.Property<Guid?>("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<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.Property<string>("ProviderKey") |
|||
.HasMaxLength(64) |
|||
.HasColumnType("varchar(64)"); |
|||
|
|||
b.Property<string>("ProviderName") |
|||
.HasMaxLength(64) |
|||
.HasColumnType("varchar(64)"); |
|||
|
|||
b.Property<string>("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<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.Property<string>("ProviderKey") |
|||
.IsRequired() |
|||
.HasMaxLength(64) |
|||
.HasColumnType("varchar(64)"); |
|||
|
|||
b.Property<string>("ProviderName") |
|||
.IsRequired() |
|||
.HasMaxLength(64) |
|||
.HasColumnType("varchar(64)"); |
|||
|
|||
b.Property<Guid?>("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<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasMaxLength(128) |
|||
.HasColumnType("varchar(128)"); |
|||
|
|||
b.Property<string>("ProviderKey") |
|||
.HasMaxLength(64) |
|||
.HasColumnType("varchar(64)"); |
|||
|
|||
b.Property<string>("ProviderName") |
|||
.HasMaxLength(64) |
|||
.HasColumnType("varchar(64)"); |
|||
|
|||
b.Property<string>("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
|
|||
} |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue