committed by
GitHub
112 changed files with 3162 additions and 396 deletions
@ -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,15 @@ |
|||||
|
<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.Features" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,27 @@ |
|||||
|
using LINGYUN.Abp.Aliyun.Localization; |
||||
|
using Volo.Abp.Features; |
||||
|
using Volo.Abp.Localization; |
||||
|
using Volo.Abp.Validation.StringValues; |
||||
|
|
||||
|
namespace LINGYUN.Abp.Aliyun.Features; |
||||
|
public class AliyunFeatureDefinitionProvider : FeatureDefinitionProvider |
||||
|
{ |
||||
|
public override void Define(IFeatureDefinitionContext context) |
||||
|
{ |
||||
|
var featureGroup = context.AddGroup( |
||||
|
name: AliyunFeatureNames.GroupName, |
||||
|
displayName: L("Features:AlibabaCloud")); |
||||
|
|
||||
|
featureGroup.AddFeature( |
||||
|
name: AliyunFeatureNames.IsEnabled, |
||||
|
defaultValue: false.ToString(), |
||||
|
displayName: L("Features:AlibabaCloud:IsEnabled"), |
||||
|
description: L("Features:AlibabaCloud:IsEnabledDesc"), |
||||
|
valueType: new ToggleStringValueType(new BooleanValueValidator())); |
||||
|
} |
||||
|
|
||||
|
private static ILocalizableString L(string name) |
||||
|
{ |
||||
|
return LocalizableString.Create<AliyunResource>(name); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,38 @@ |
|||||
|
namespace LINGYUN.Abp.Aliyun.Features; |
||||
|
public static class AliyunFeatureNames |
||||
|
{ |
||||
|
public const string GroupName = "AlibabaCloud"; |
||||
|
|
||||
|
public const string IsEnabled = GroupName + ".IsEnabled"; |
||||
|
|
||||
|
public static class Sms |
||||
|
{ |
||||
|
public const string Default = GroupName + ".Sms"; |
||||
|
|
||||
|
public const string IsEnabled = Default + ".IsEnabled"; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 发送次数上限
|
||||
|
/// </summary>
|
||||
|
public const string SendLimit = Default + ".SendLimit"; |
||||
|
/// <summary>
|
||||
|
/// 发送次数上限时长
|
||||
|
/// </summary>
|
||||
|
public const string SendLimitInterval = Default + ".SendLimitInterval"; |
||||
|
/// <summary>
|
||||
|
/// 默认发送次数上限
|
||||
|
/// </summary>
|
||||
|
public const int DefaultSendLimit = 1000; |
||||
|
/// <summary>
|
||||
|
/// 默认发送次数上限时长
|
||||
|
/// </summary>
|
||||
|
public const int DefaultSendLimitInterval = 1; |
||||
|
} |
||||
|
|
||||
|
public static class Oss |
||||
|
{ |
||||
|
public const string Default = GroupName + ".Sms"; |
||||
|
|
||||
|
public const string IsEnabled = GroupName + ".IsEnabled"; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,53 @@ |
|||||
|
using LINGYUN.Abp.Aliyun.Localization; |
||||
|
using Volo.Abp.Features; |
||||
|
using Volo.Abp.Localization; |
||||
|
using Volo.Abp.Validation.StringValues; |
||||
|
|
||||
|
namespace LINGYUN.Abp.Aliyun.Features; |
||||
|
public class AliyunFeatureDefinitionProvider : FeatureDefinitionProvider |
||||
|
{ |
||||
|
public override void Define(IFeatureDefinitionContext context) |
||||
|
{ |
||||
|
var featureGroup = context.AddGroup( |
||||
|
name: AliyunFeatureNames.GroupName, |
||||
|
displayName: L("Features:AlibabaCloud")); |
||||
|
|
||||
|
featureGroup.AddFeature( |
||||
|
name: AliyunFeatureNames.Enable, |
||||
|
defaultValue: false.ToString(), |
||||
|
displayName: L("Features:AlibabaCloud:IsEnabled"), |
||||
|
description: L("Features:AlibabaCloud:IsEnabledDesc"), |
||||
|
valueType: new ToggleStringValueType(new BooleanValueValidator())); |
||||
|
|
||||
|
var smsFeature = featureGroup.AddFeature( |
||||
|
name: AliyunFeatureNames.Sms.Enable, |
||||
|
defaultValue: false.ToString(), |
||||
|
displayName: L("Features:AlibabaCloud:Sms"), |
||||
|
description: L("Features:AlibabaCloud:SmsDesc"), |
||||
|
valueType: new ToggleStringValueType(new BooleanValueValidator())); |
||||
|
smsFeature.CreateChild( |
||||
|
name: AliyunFeatureNames.Sms.SendLimit, |
||||
|
defaultValue: AliyunFeatureNames.Sms.DefaultSendLimit.ToString(), |
||||
|
displayName: L("Features:AlibabaCloud:Sms.SendLimit"), |
||||
|
description: L("Features:AlibabaCloud:Sms.SendLimitDesc"), |
||||
|
valueType: new FreeTextStringValueType(new NumericValueValidator(1, 100_0000))); |
||||
|
smsFeature.CreateChild( |
||||
|
name: AliyunFeatureNames.Sms.SendLimitInterval, |
||||
|
defaultValue: AliyunFeatureNames.Sms.DefaultSendLimitInterval.ToString(), |
||||
|
displayName: L("Features:AlibabaCloud:Sms.SendLimitInterval"), |
||||
|
description: L("Features:AlibabaCloud:Sms.SendLimitIntervalDesc"), |
||||
|
valueType: new FreeTextStringValueType(new NumericValueValidator(1, 100_0000))); |
||||
|
|
||||
|
var blobFeature = featureGroup.AddFeature( |
||||
|
name: AliyunFeatureNames.BlobStoring.Enable, |
||||
|
defaultValue: false.ToString(), |
||||
|
displayName: L("Features:AlibabaCloud:Oss"), |
||||
|
description: L("Features:AlibabaCloud:OssDesc"), |
||||
|
valueType: new ToggleStringValueType(new BooleanValueValidator())); |
||||
|
} |
||||
|
|
||||
|
private static ILocalizableString L(string name) |
||||
|
{ |
||||
|
return LocalizableString.Create<AliyunResource>(name); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,38 @@ |
|||||
|
namespace LINGYUN.Abp.Aliyun.Features; |
||||
|
public static class AliyunFeatureNames |
||||
|
{ |
||||
|
public const string GroupName = "AlibabaCloud"; |
||||
|
|
||||
|
public const string Enable = GroupName + ".Enable"; |
||||
|
|
||||
|
public static class Sms |
||||
|
{ |
||||
|
public const string Default = GroupName + ".Sms"; |
||||
|
|
||||
|
public const string Enable = Default + ".Enable"; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 发送次数上限
|
||||
|
/// </summary>
|
||||
|
public const string SendLimit = Default + ".SendLimit"; |
||||
|
/// <summary>
|
||||
|
/// 发送次数上限时长
|
||||
|
/// </summary>
|
||||
|
public const string SendLimitInterval = Default + ".SendLimitInterval"; |
||||
|
/// <summary>
|
||||
|
/// 默认发送次数上限
|
||||
|
/// </summary>
|
||||
|
public const int DefaultSendLimit = 1000; |
||||
|
/// <summary>
|
||||
|
/// 默认发送次数上限时长
|
||||
|
/// </summary>
|
||||
|
public const int DefaultSendLimitInterval = 1; |
||||
|
} |
||||
|
|
||||
|
public static class BlobStoring |
||||
|
{ |
||||
|
public const string Default = GroupName + ".BlobStoring"; |
||||
|
|
||||
|
public const string Enable = Default + ".Enable"; |
||||
|
} |
||||
|
} |
||||
@ -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>net8.0</TargetFramework> |
||||
|
<RootNamespace /> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Volo.Abp.IdentityServer.Domain" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\LINGYUN.Abp.OpenApi\LINGYUN.Abp.OpenApi.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,11 @@ |
|||||
|
using Volo.Abp.IdentityServer; |
||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace LINGYUN.Abp.OpenApi.IdentityServer; |
||||
|
|
||||
|
[DependsOn( |
||||
|
typeof(AbpOpenApiModule), |
||||
|
typeof(AbpIdentityServerDomainModule))] |
||||
|
public class AbpOpenApiIdentityServerModule : AbpModule |
||||
|
{ |
||||
|
} |
||||
@ -0,0 +1,70 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
using Microsoft.Extensions.Logging.Abstractions; |
||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.Guids; |
||||
|
using Volo.Abp.IdentityServer.Clients; |
||||
|
|
||||
|
namespace LINGYUN.Abp.OpenApi.IdentityServer; |
||||
|
|
||||
|
[Dependency(ServiceLifetime.Transient, ReplaceServices = true)] |
||||
|
public class IdentityServerAppKeyStore : IAppKeyStore, ITransientDependency |
||||
|
{ |
||||
|
public ILogger<IdentityServerAppKeyStore> Logger { protected get; set; } |
||||
|
|
||||
|
private readonly IGuidGenerator _guidGenerator; |
||||
|
private readonly IClientRepository _clientRepository; |
||||
|
|
||||
|
public IdentityServerAppKeyStore( |
||||
|
IGuidGenerator guidGenerator, |
||||
|
IClientRepository clientRepository) |
||||
|
{ |
||||
|
_guidGenerator = guidGenerator; |
||||
|
_clientRepository = clientRepository; |
||||
|
|
||||
|
Logger = NullLogger<IdentityServerAppKeyStore>.Instance; |
||||
|
} |
||||
|
|
||||
|
public async virtual Task<AppDescriptor> FindAsync(string appKey, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
var client = await _clientRepository.FindByClientIdAsync(appKey, cancellationToken: cancellationToken); |
||||
|
if (client != null) |
||||
|
{ |
||||
|
int? signLifeTime = null; |
||||
|
|
||||
|
var appSecret = client.FindSecret(nameof(AppDescriptor.AppSecret)); |
||||
|
if (appSecret == null) |
||||
|
{ |
||||
|
Logger.LogWarning("Found a client {ClientId} that meets the criteria, but did not specify the client key [AppSecret]", client.ClientId); |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
var signLifeTimeProp = client.FindProperty(nameof(AppDescriptor.SignLifetime)); |
||||
|
if (signLifeTimeProp != null && int.TryParse(signLifeTimeProp.Value, out var time)) |
||||
|
{ |
||||
|
signLifeTime = time; |
||||
|
} |
||||
|
|
||||
|
return new AppDescriptor(client.ClientName, client.ClientId, appSecret.Value, signLifeTime: signLifeTime); |
||||
|
} |
||||
|
|
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
public async virtual Task StoreAsync(AppDescriptor descriptor, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
var client = new Client(_guidGenerator.Create(), descriptor.AppKey) |
||||
|
{ |
||||
|
ClientName = descriptor.AppName, |
||||
|
}; |
||||
|
client.AddSecret(descriptor.AppSecret); |
||||
|
if (descriptor.SignLifetime.HasValue) |
||||
|
{ |
||||
|
client.AddProperty(nameof(AppDescriptor.SignLifetime), descriptor.SignLifetime.Value.ToString()); |
||||
|
} |
||||
|
|
||||
|
await _clientRepository.InsertAsync(client, cancellationToken: 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,19 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\..\..\configureawait.props" /> |
||||
|
<Import Project="..\..\..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>net8.0</TargetFramework> |
||||
|
<RootNamespace /> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Volo.Abp.OpenIddict.Domain" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\LINGYUN.Abp.OpenApi\LINGYUN.Abp.OpenApi.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,11 @@ |
|||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Abp.OpenIddict; |
||||
|
|
||||
|
namespace LINGYUN.Abp.OpenApi.OpenIddict; |
||||
|
|
||||
|
[DependsOn( |
||||
|
typeof(AbpOpenApiModule), |
||||
|
typeof(AbpOpenIddictDomainModule))] |
||||
|
public class AbpOpenApiOpenIddictModule : AbpModule |
||||
|
{ |
||||
|
} |
||||
@ -0,0 +1,59 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.Guids; |
||||
|
using Volo.Abp.OpenIddict.Applications; |
||||
|
|
||||
|
namespace LINGYUN.Abp.OpenApi.OpenIddict; |
||||
|
|
||||
|
[Dependency(ServiceLifetime.Transient, ReplaceServices = true)] |
||||
|
public class OpenIddictAppKeyStore : IAppKeyStore, ITransientDependency |
||||
|
{ |
||||
|
private readonly IAbpOpenIdApplicationStore _appStore; |
||||
|
private readonly IGuidGenerator _guidGenerator; |
||||
|
|
||||
|
public OpenIddictAppKeyStore( |
||||
|
IAbpOpenIdApplicationStore appStore, |
||||
|
IGuidGenerator guidGenerator) |
||||
|
{ |
||||
|
_appStore = appStore; |
||||
|
_guidGenerator = guidGenerator; |
||||
|
} |
||||
|
|
||||
|
public async virtual Task<AppDescriptor> FindAsync(string appKey, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
var application = await _appStore.FindByClientIdAsync(appKey, cancellationToken); |
||||
|
if (application != null) |
||||
|
{ |
||||
|
int? signLifeTime = null; |
||||
|
|
||||
|
var signLifeTimeProp = application.GetProperty(nameof(AppDescriptor.SignLifetime)); |
||||
|
if (signLifeTimeProp != null && int.TryParse(signLifeTimeProp.ToString(), out var time)) |
||||
|
{ |
||||
|
signLifeTime = time; |
||||
|
} |
||||
|
|
||||
|
return new AppDescriptor(application.DisplayName, application.ClientId, application.ClientSecret, signLifeTime: signLifeTime); |
||||
|
} |
||||
|
|
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
public async virtual Task StoreAsync(AppDescriptor descriptor, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
var application = new OpenIddictApplicationModel |
||||
|
{ |
||||
|
Id = _guidGenerator.Create(), |
||||
|
ClientId = descriptor.AppKey, |
||||
|
ClientSecret = descriptor.AppSecret, |
||||
|
DisplayName = descriptor.AppName, |
||||
|
}; |
||||
|
if (descriptor.SignLifetime.HasValue) |
||||
|
{ |
||||
|
application.SetProperty(nameof(AppDescriptor.SignLifetime), descriptor.SignLifetime); |
||||
|
} |
||||
|
await _appStore.CreateAsync(application, cancellationToken); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace LINGYUN.Abp.OpenApi; |
||||
|
|
||||
|
[Dependency(ServiceLifetime.Singleton, TryRegister = true)] |
||||
|
public class AlwaysAllowClientChecker : IClientChecker |
||||
|
{ |
||||
|
public Task<bool> IsGrantAsync(string clientId, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
return Task.FromResult(true); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace LINGYUN.Abp.OpenApi; |
||||
|
|
||||
|
[Dependency(ServiceLifetime.Singleton, TryRegister = true)] |
||||
|
public class AlwaysAllowIpAddressChecker : IIpAddressChecker |
||||
|
{ |
||||
|
public Task<bool> IsGrantAsync(string ipAddress, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
return Task.FromResult(true); |
||||
|
} |
||||
|
} |
||||
@ -1,9 +1,11 @@ |
|||||
using System.Threading.Tasks; |
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
namespace LINGYUN.Abp.OpenApi |
namespace LINGYUN.Abp.OpenApi; |
||||
|
|
||||
|
public interface IAppKeyStore |
||||
{ |
{ |
||||
public interface IAppKeyStore |
Task<AppDescriptor> FindAsync(string appKey, CancellationToken cancellationToken = default); |
||||
{ |
|
||||
Task<AppDescriptor> FindAsync(string appKey); |
Task StoreAsync(AppDescriptor descriptor, CancellationToken cancellationToken = default); |
||||
} |
|
||||
} |
} |
||||
|
|||||
@ -0,0 +1,9 @@ |
|||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace LINGYUN.Abp.OpenApi; |
||||
|
|
||||
|
public interface IClientChecker |
||||
|
{ |
||||
|
Task<bool> IsGrantAsync(string clientId, CancellationToken cancellationToken = default); |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace LINGYUN.Abp.OpenApi; |
||||
|
public interface IIpAddressChecker |
||||
|
{ |
||||
|
Task<bool> IsGrantAsync(string ipAddress, CancellationToken cancellationToken = default); |
||||
|
} |
||||
@ -0,0 +1,938 @@ |
|||||
|
// <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.EntityFrameworkCore.Migrations |
||||
|
{ |
||||
|
[DbContext(typeof(BackendAdminMigrationsDbContext))] |
||||
|
[Migration("20240527092536_Remote-Tenant-Id-With-Text-Template")] |
||||
|
partial class RemoteTenantIdWithTextTemplate |
||||
|
{ |
||||
|
/// <inheritdoc />
|
||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
||||
|
{ |
||||
|
#pragma warning disable 612, 618
|
||||
|
modelBuilder |
||||
|
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) |
||||
|
.HasAnnotation("ProductVersion", "8.0.0") |
||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 64); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.DataProtectionManagement.EntityPropertyInfo", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)") |
||||
|
.HasColumnName("DisplayName"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)") |
||||
|
.HasColumnName("Name"); |
||||
|
|
||||
|
b.Property<string>("TypeFullName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)") |
||||
|
.HasColumnName("TypeFullName"); |
||||
|
|
||||
|
b.Property<Guid>("TypeInfoId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("ValueRange") |
||||
|
.HasMaxLength(512) |
||||
|
.HasColumnType("varchar(512)") |
||||
|
.HasColumnName("ValueRange"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TypeInfoId", "TypeFullName"); |
||||
|
|
||||
|
b.ToTable("AbpAuthEntityProperties", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.DataProtectionManagement.EntityTypeInfo", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)") |
||||
|
.HasColumnName("DisplayName"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.IsRequired() |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<bool>("IsAuditEnabled") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
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)") |
||||
|
.HasColumnName("Name"); |
||||
|
|
||||
|
b.Property<string>("TypeFullName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)") |
||||
|
.HasColumnName("TypeFullName"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TypeFullName"); |
||||
|
|
||||
|
b.ToTable("AbpAuthEntitites", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.DataProtectionManagement.OrganizationUnitEntityRule", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("AllowProperties") |
||||
|
.HasMaxLength(512) |
||||
|
.HasColumnType("varchar(512)") |
||||
|
.HasColumnName("AllowProperties"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("EntityTypeFullName") |
||||
|
.HasColumnType("longtext"); |
||||
|
|
||||
|
b.Property<Guid>("EntityTypeId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.IsRequired() |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<string>("FilterGroup") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("FilterGroup"); |
||||
|
|
||||
|
b.Property<bool>("IsEnabled") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<int>("Operation") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<string>("OrgCode") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)") |
||||
|
.HasColumnName("OrgCode"); |
||||
|
|
||||
|
b.Property<Guid>("OrgId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("EntityTypeId"); |
||||
|
|
||||
|
b.ToTable("AbpAuthOrganizationUnitEntityRules", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.DataProtectionManagement.RoleEntityRule", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("AllowProperties") |
||||
|
.HasMaxLength(512) |
||||
|
.HasColumnType("varchar(512)") |
||||
|
.HasColumnName("AllowProperties"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("EntityTypeFullName") |
||||
|
.HasColumnType("longtext"); |
||||
|
|
||||
|
b.Property<Guid>("EntityTypeId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.IsRequired() |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<string>("FilterGroup") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("FilterGroup"); |
||||
|
|
||||
|
b.Property<bool>("IsEnabled") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<int>("Operation") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<Guid>("RoleId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("RoleName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)") |
||||
|
.HasColumnName("RoleName"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("EntityTypeId"); |
||||
|
|
||||
|
b.ToTable("AbpAuthRoleEntityRules", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.Saas.Editions.Edition", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.IsRequired() |
||||
|
.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<int>("EntityVersion") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.IsRequired() |
||||
|
.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() |
||||
|
.IsRequired() |
||||
|
.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<int>("EntityVersion") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.IsRequired() |
||||
|
.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.Property<string>("NormalizedName") |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("EditionId"); |
||||
|
|
||||
|
b.HasIndex("Name"); |
||||
|
|
||||
|
b.HasIndex("NormalizedName"); |
||||
|
|
||||
|
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") |
||||
|
.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.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Name") |
||||
|
.HasDatabaseName("IX_Tenant_Text_Template_Name"); |
||||
|
|
||||
|
b.ToTable("AbpTextTemplates", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.TextTemplating.TextTemplateDefinition", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<string>("DefaultCultureName") |
||||
|
.HasMaxLength(30) |
||||
|
.HasColumnType("varchar(30)") |
||||
|
.HasColumnName("DefaultCultureName"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(512) |
||||
|
.HasColumnType("varchar(512)") |
||||
|
.HasColumnName("DisplayName"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.IsRequired() |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<bool>("IsInlineLocalized") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<bool>("IsLayout") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<bool>("IsStatic") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<string>("Layout") |
||||
|
.HasMaxLength(60) |
||||
|
.HasColumnType("varchar(60)") |
||||
|
.HasColumnName("Layout"); |
||||
|
|
||||
|
b.Property<string>("LocalizationResourceName") |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)") |
||||
|
.HasColumnName("LocalizationResourceName"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)") |
||||
|
.HasColumnName("Name"); |
||||
|
|
||||
|
b.Property<string>("RenderEngine") |
||||
|
.HasMaxLength(30) |
||||
|
.HasColumnType("varchar(30)") |
||||
|
.HasColumnName("RenderEngine"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.ToTable("AbpTextTemplateDefinitions", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureDefinitionRecord", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("AllowedProviders") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<string>("DefaultValue") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<string>("GroupName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<bool>("IsAvailableToHost") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<bool>("IsVisibleToClients") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<string>("ParentName") |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<string>("ValueType") |
||||
|
.HasMaxLength(2048) |
||||
|
.HasColumnType("varchar(2048)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("GroupName"); |
||||
|
|
||||
|
b.HasIndex("Name") |
||||
|
.IsUnique(); |
||||
|
|
||||
|
b.ToTable("AbpFeatures", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureGroupDefinitionRecord", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Name") |
||||
|
.IsUnique(); |
||||
|
|
||||
|
b.ToTable("AbpFeatureGroups", (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.PermissionDefinitionRecord", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<string>("GroupName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<bool>("IsEnabled") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<byte>("MultiTenancySide") |
||||
|
.HasColumnType("tinyint unsigned"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<string>("ParentName") |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<string>("Providers") |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<string>("StateCheckers") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("GroupName"); |
||||
|
|
||||
|
b.HasIndex("Name") |
||||
|
.IsUnique(); |
||||
|
|
||||
|
b.ToTable("AbpPermissions", (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.PermissionManagement.PermissionGroupDefinitionRecord", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Name") |
||||
|
.IsUnique(); |
||||
|
|
||||
|
b.ToTable("AbpPermissionGroups", (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("Volo.Abp.SettingManagement.SettingDefinitionRecord", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("DefaultValue") |
||||
|
.HasMaxLength(2048) |
||||
|
.HasColumnType("varchar(2048)"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(512) |
||||
|
.HasColumnType("varchar(512)"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<bool>("IsEncrypted") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<bool>("IsInherited") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<bool>("IsVisibleToClients") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<string>("Providers") |
||||
|
.HasMaxLength(1024) |
||||
|
.HasColumnType("varchar(1024)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Name") |
||||
|
.IsUnique(); |
||||
|
|
||||
|
b.ToTable("AbpSettingDefinitions", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.DataProtectionManagement.EntityPropertyInfo", b => |
||||
|
{ |
||||
|
b.HasOne("LINGYUN.Abp.DataProtectionManagement.EntityTypeInfo", "TypeInfo") |
||||
|
.WithMany("Properties") |
||||
|
.HasForeignKey("TypeInfoId") |
||||
|
.OnDelete(DeleteBehavior.Cascade) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
b.Navigation("TypeInfo"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.DataProtectionManagement.OrganizationUnitEntityRule", b => |
||||
|
{ |
||||
|
b.HasOne("LINGYUN.Abp.DataProtectionManagement.EntityTypeInfo", "EntityTypeInfo") |
||||
|
.WithMany() |
||||
|
.HasForeignKey("EntityTypeId") |
||||
|
.OnDelete(DeleteBehavior.Cascade) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
b.Navigation("EntityTypeInfo"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.DataProtectionManagement.RoleEntityRule", b => |
||||
|
{ |
||||
|
b.HasOne("LINGYUN.Abp.DataProtectionManagement.EntityTypeInfo", "EntityTypeInfo") |
||||
|
.WithMany() |
||||
|
.HasForeignKey("EntityTypeId") |
||||
|
.OnDelete(DeleteBehavior.Cascade) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
b.Navigation("EntityTypeInfo"); |
||||
|
}); |
||||
|
|
||||
|
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.DataProtectionManagement.EntityTypeInfo", b => |
||||
|
{ |
||||
|
b.Navigation("Properties"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.Tenant", b => |
||||
|
{ |
||||
|
b.Navigation("ConnectionStrings"); |
||||
|
}); |
||||
|
#pragma warning restore 612, 618
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,48 @@ |
|||||
|
using System; |
||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace LY.MicroService.BackendAdmin.EntityFrameworkCore.Migrations |
||||
|
{ |
||||
|
/// <inheritdoc />
|
||||
|
public partial class RemoteTenantIdWithTextTemplate : Migration |
||||
|
{ |
||||
|
/// <inheritdoc />
|
||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.DropIndex( |
||||
|
name: "IX_Tenant_Text_Template_Name", |
||||
|
table: "AbpTextTemplates"); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "TenantId", |
||||
|
table: "AbpTextTemplates"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_Tenant_Text_Template_Name", |
||||
|
table: "AbpTextTemplates", |
||||
|
column: "Name"); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.DropIndex( |
||||
|
name: "IX_Tenant_Text_Template_Name", |
||||
|
table: "AbpTextTemplates"); |
||||
|
|
||||
|
migrationBuilder.AddColumn<Guid>( |
||||
|
name: "TenantId", |
||||
|
table: "AbpTextTemplates", |
||||
|
type: "char(36)", |
||||
|
nullable: true, |
||||
|
collation: "ascii_general_ci"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_Tenant_Text_Template_Name", |
||||
|
table: "AbpTextTemplates", |
||||
|
columns: new[] { "TenantId", "Name" }); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,7 +0,0 @@ |
|||||
using System.Threading.Tasks; |
|
||||
|
|
||||
namespace LINGYUN.Abp.TextTemplating; |
|
||||
public interface IStaticTemplateDefinitionSaver |
|
||||
{ |
|
||||
Task SaveAsync(); |
|
||||
} |
|
||||
@ -0,0 +1,9 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace LINGYUN.Abp.TextTemplating; |
||||
|
public interface IStaticTemplateSaver |
||||
|
{ |
||||
|
Task SaveDefinitionTemplateAsync(); |
||||
|
|
||||
|
Task SaveTemplateContentAsync(); |
||||
|
} |
||||
@ -1,96 +1,129 @@ |
|||||
using Microsoft.Extensions.Options; |
using Microsoft.Extensions.Options; |
||||
using System.Collections.Generic; |
using System.Collections.Generic; |
||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
using Volo.Abp.Caching; |
using Volo.Abp.Caching; |
||||
using Volo.Abp.Data; |
using Volo.Abp.Data; |
||||
using Volo.Abp.DependencyInjection; |
using Volo.Abp.DependencyInjection; |
||||
using Volo.Abp.DistributedLocking; |
using Volo.Abp.DistributedLocking; |
||||
using Volo.Abp.Guids; |
using Volo.Abp.Guids; |
||||
using Volo.Abp.Localization; |
using Volo.Abp.Localization; |
||||
using Volo.Abp.TextTemplating; |
using Volo.Abp.TextTemplating; |
||||
using Volo.Abp.Uow; |
using Volo.Abp.Uow; |
||||
|
|
||||
namespace LINGYUN.Abp.TextTemplating; |
namespace LINGYUN.Abp.TextTemplating; |
||||
|
|
||||
public class StaticTemplateDefinitionSaver : IStaticTemplateDefinitionSaver, ITransientDependency |
public class StaticTemplateSaver : IStaticTemplateSaver, ITransientDependency |
||||
{ |
{ |
||||
protected AbpDistributedCacheOptions CacheOptions { get; } |
protected AbpDistributedCacheOptions CacheOptions { get; } |
||||
protected IGuidGenerator GuidGenerator { get; } |
protected IGuidGenerator GuidGenerator { get; } |
||||
protected IAbpDistributedLock DistributedLock { get; } |
protected IAbpDistributedLock DistributedLock { get; } |
||||
protected ITextTemplateDefinitionRepository TemplateDefinitionRepository { get; } |
protected ITextTemplateRepository TextTemplateRepository { get; } |
||||
protected AbpTextTemplatingCachingOptions TemplatingCachingOptions { get; } |
protected ITextTemplateDefinitionRepository TemplateDefinitionRepository { get; } |
||||
protected IStaticTemplateDefinitionStore StaticTemplateDefinitionStore { get; } |
protected AbpTextTemplatingCachingOptions TemplatingCachingOptions { get; } |
||||
protected ILocalizableStringSerializer LocalizableStringSerializer { get; } |
protected IStaticTemplateDefinitionStore StaticTemplateDefinitionStore { get; } |
||||
|
protected ILocalizableStringSerializer LocalizableStringSerializer { get; } |
||||
public StaticTemplateDefinitionSaver( |
protected ITemplateContentProvider TemplateContentProvider { get; } |
||||
IOptions<AbpDistributedCacheOptions> cacheOptions, |
|
||||
IOptions<AbpTextTemplatingCachingOptions> templatingCachingOptions, |
public StaticTemplateSaver( |
||||
IGuidGenerator guidGenerator, |
IOptions<AbpDistributedCacheOptions> cacheOptions, |
||||
IAbpDistributedLock distributedLock, |
IOptions<AbpTextTemplatingCachingOptions> templatingCachingOptions, |
||||
ITextTemplateDefinitionRepository templateDefinitionRepository, |
IGuidGenerator guidGenerator, |
||||
IStaticTemplateDefinitionStore staticTemplateDefinitionStore, |
IAbpDistributedLock distributedLock, |
||||
ILocalizableStringSerializer localizableStringSerializer) |
ITextTemplateRepository textTemplateRepository, |
||||
{ |
ITextTemplateDefinitionRepository templateDefinitionRepository, |
||||
CacheOptions = cacheOptions.Value; |
IStaticTemplateDefinitionStore staticTemplateDefinitionStore, |
||||
GuidGenerator = guidGenerator; |
ILocalizableStringSerializer localizableStringSerializer, |
||||
DistributedLock = distributedLock; |
ITemplateContentProvider templateContentProvider) |
||||
TemplateDefinitionRepository = templateDefinitionRepository; |
{ |
||||
TemplatingCachingOptions = templatingCachingOptions.Value; |
CacheOptions = cacheOptions.Value; |
||||
StaticTemplateDefinitionStore = staticTemplateDefinitionStore; |
GuidGenerator = guidGenerator; |
||||
LocalizableStringSerializer = localizableStringSerializer; |
DistributedLock = distributedLock; |
||||
} |
TextTemplateRepository = textTemplateRepository; |
||||
|
TemplateDefinitionRepository = templateDefinitionRepository; |
||||
[UnitOfWork] |
TemplatingCachingOptions = templatingCachingOptions.Value; |
||||
public async virtual Task SaveAsync() |
StaticTemplateDefinitionStore = staticTemplateDefinitionStore; |
||||
{ |
LocalizableStringSerializer = localizableStringSerializer; |
||||
if (TemplatingCachingOptions.SaveStaticTemplateDefinitionToDatabase) |
TemplateContentProvider = templateContentProvider; |
||||
{ |
} |
||||
await using var commonLockHandle = await DistributedLock |
|
||||
.TryAcquireAsync(GetCommonDistributedLockKey(), TemplatingCachingOptions.TemplateDefinitionsCacheStampTimeOut); |
[UnitOfWork] |
||||
|
public async virtual Task SaveDefinitionTemplateAsync() |
||||
if (commonLockHandle == null) |
{ |
||||
{ |
if (TemplatingCachingOptions.SaveStaticTemplateDefinitionToDatabase) |
||||
return; |
{ |
||||
} |
await using var commonLockHandle = await DistributedLock |
||||
|
.TryAcquireAsync(GetCommonDistributedLockKey(), TemplatingCachingOptions.TemplateDefinitionsCacheStampTimeOut); |
||||
var templateDefinitions = await StaticTemplateDefinitionStore.GetAllAsync(); |
|
||||
|
if (commonLockHandle == null) |
||||
var saveNewTemplateDefinitionRecords = new List<TextTemplateDefinition>(); |
{ |
||||
|
return; |
||||
foreach (var templateDefinition in templateDefinitions) |
} |
||||
{ |
|
||||
if (await TemplateDefinitionRepository.FindByNameAsync(templateDefinition.Name) != null) |
var templateDefinitions = await StaticTemplateDefinitionStore.GetAllAsync(); |
||||
{ |
|
||||
continue; |
var saveNewTemplateDefinitionRecords = new List<TextTemplateDefinition>(); |
||||
} |
|
||||
|
foreach (var templateDefinition in templateDefinitions) |
||||
var templateDefinitionRecord = new TextTemplateDefinition( |
{ |
||||
GuidGenerator.Create(), |
if (await TemplateDefinitionRepository.FindByNameAsync(templateDefinition.Name) != null) |
||||
templateDefinition.Name, |
{ |
||||
LocalizableStringSerializer.Serialize(templateDefinition.DisplayName), |
continue; |
||||
templateDefinition.IsLayout, |
} |
||||
templateDefinition.Layout, |
|
||||
templateDefinition.IsInlineLocalized, |
var templateDefinitionRecord = new TextTemplateDefinition( |
||||
templateDefinition.DefaultCultureName, |
GuidGenerator.Create(), |
||||
templateDefinition.RenderEngine) |
templateDefinition.Name, |
||||
{ |
LocalizableStringSerializer.Serialize(templateDefinition.DisplayName), |
||||
IsStatic = true |
templateDefinition.IsLayout, |
||||
}; |
templateDefinition.Layout, |
||||
|
templateDefinition.IsInlineLocalized, |
||||
foreach (var property in templateDefinition.Properties) |
templateDefinition.DefaultCultureName, |
||||
{ |
templateDefinition.LocalizationResourceName, |
||||
templateDefinitionRecord.SetProperty(property.Key, property.Value); |
templateDefinition.RenderEngine) |
||||
} |
{ |
||||
|
IsStatic = true |
||||
saveNewTemplateDefinitionRecords.Add(templateDefinitionRecord); |
}; |
||||
} |
|
||||
|
foreach (var property in templateDefinition.Properties) |
||||
await TemplateDefinitionRepository.InsertManyAsync(saveNewTemplateDefinitionRecords); |
{ |
||||
} |
templateDefinitionRecord.SetProperty(property.Key, property.Value); |
||||
} |
} |
||||
|
|
||||
protected virtual string GetCommonDistributedLockKey() |
saveNewTemplateDefinitionRecords.Add(templateDefinitionRecord); |
||||
{ |
} |
||||
return $"{CacheOptions.KeyPrefix}_Common_AbpTemplateDefinitionStaticSaverLock"; |
|
||||
} |
await TemplateDefinitionRepository.InsertManyAsync(saveNewTemplateDefinitionRecords); |
||||
} |
} |
||||
|
} |
||||
|
|
||||
|
[UnitOfWork] |
||||
|
public async virtual Task SaveTemplateContentAsync() |
||||
|
{ |
||||
|
var saveNewTemplates = new List<TextTemplate>(); |
||||
|
var templateDefinitions = await StaticTemplateDefinitionStore.GetAllAsync(); |
||||
|
foreach (var templateDefinition in templateDefinitions) |
||||
|
{ |
||||
|
var culture = templateDefinition.IsInlineLocalized ? null : templateDefinition.DefaultCultureName; |
||||
|
if (await TextTemplateRepository.FindByNameAsync(templateDefinition.Name, culture) != null) |
||||
|
{ |
||||
|
continue; |
||||
|
} |
||||
|
|
||||
|
var content = await TemplateContentProvider.GetContentOrNullAsync(templateDefinition, culture); |
||||
|
var textTemplate = new TextTemplate( |
||||
|
GuidGenerator.Create(), |
||||
|
templateDefinition.Name, |
||||
|
LocalizableStringSerializer.Serialize(templateDefinition.DisplayName), |
||||
|
content, |
||||
|
culture); |
||||
|
saveNewTemplates.Add(textTemplate); |
||||
|
} |
||||
|
|
||||
|
await TextTemplateRepository.InsertManyAsync(saveNewTemplates); |
||||
|
} |
||||
|
|
||||
|
protected virtual string GetCommonDistributedLockKey() |
||||
|
{ |
||||
|
return $"{CacheOptions.KeyPrefix}_Common_AbpTemplateDefinitionStaticSaverLock"; |
||||
|
} |
||||
|
} |
||||
@ -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,18 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\..\..\configureawait.props" /> |
||||
|
<Import Project="..\..\..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netstandard2.0</TargetFramework> |
||||
|
<Nullable>enable</Nullable> |
||||
|
<WarningsAsErrors>Nullable</WarningsAsErrors> |
||||
|
<RootNamespace /> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Scriban" /> |
||||
|
<PackageReference Include="Volo.Abp.TextTemplating.Core" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,17 @@ |
|||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Abp.TextTemplating; |
||||
|
|
||||
|
namespace LINGYUN.Abp.TextTemplating.Scriban; |
||||
|
|
||||
|
[DependsOn(typeof(AbpTextTemplatingCoreModule))] |
||||
|
public class AbpTextTemplatingScribanModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
Configure<AbpTextTemplatingOptions>(options => |
||||
|
{ |
||||
|
options.DefaultRenderingEngine = ScribanTemplateRenderingEngine.EngineName; |
||||
|
options.RenderingEngines[ScribanTemplateRenderingEngine.EngineName] = typeof(ScribanTemplateRenderingEngine); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
using JetBrains.Annotations; |
||||
|
using Volo.Abp.TextTemplating; |
||||
|
|
||||
|
namespace LINGYUN.Abp.TextTemplating.Scriban; |
||||
|
|
||||
|
public static class ScribanTemplateDefinitionExtensions |
||||
|
{ |
||||
|
public static TemplateDefinition WithScribanEngine([NotNull] this TemplateDefinition templateDefinition) |
||||
|
{ |
||||
|
return templateDefinition.WithRenderEngine(ScribanTemplateRenderingEngine.EngineName); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,64 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.Extensions.Localization; |
||||
|
using Scriban; |
||||
|
using Scriban.Runtime; |
||||
|
using Scriban.Syntax; |
||||
|
|
||||
|
namespace LINGYUN.Abp.TextTemplating.Scriban; |
||||
|
|
||||
|
public class ScribanTemplateLocalizer : IScriptCustomFunction |
||||
|
{ |
||||
|
private readonly IStringLocalizer _localizer; |
||||
|
|
||||
|
public ScribanTemplateLocalizer(IStringLocalizer localizer) |
||||
|
{ |
||||
|
_localizer = localizer; |
||||
|
} |
||||
|
|
||||
|
public object Invoke(TemplateContext context, ScriptNode callerContext, ScriptArray arguments, |
||||
|
ScriptBlockStatement blockStatement) |
||||
|
{ |
||||
|
return GetString(arguments); |
||||
|
} |
||||
|
|
||||
|
public ValueTask<object> InvokeAsync(TemplateContext context, ScriptNode callerContext, ScriptArray arguments, |
||||
|
ScriptBlockStatement blockStatement) |
||||
|
{ |
||||
|
return new ValueTask<object>(GetString(arguments)); |
||||
|
} |
||||
|
|
||||
|
private string GetString(ScriptArray arguments) |
||||
|
{ |
||||
|
if (arguments.IsNullOrEmpty()) |
||||
|
{ |
||||
|
return string.Empty; |
||||
|
} |
||||
|
|
||||
|
var name = arguments[0]; |
||||
|
if (name == null || name.ToString().IsNullOrWhiteSpace()) |
||||
|
{ |
||||
|
return string.Empty; |
||||
|
} |
||||
|
|
||||
|
var args = arguments.Skip(1).Where(x => x != null && !x.ToString().IsNullOrWhiteSpace()).ToArray(); |
||||
|
return args.Any() ? _localizer[name.ToString()!, args] : _localizer[name.ToString()!]; |
||||
|
} |
||||
|
|
||||
|
public int RequiredParameterCount => 1; |
||||
|
|
||||
|
public int ParameterCount => ScriptFunctionCall.MaximumParameterCount - 1; |
||||
|
|
||||
|
public ScriptVarParamKind VarParamKind => ScriptVarParamKind.Direct; |
||||
|
|
||||
|
public Type ReturnType => typeof(object); |
||||
|
|
||||
|
public ScriptParameterInfo GetParameterInfo(int index) |
||||
|
{ |
||||
|
return index == 0 |
||||
|
? new ScriptParameterInfo(typeof(string), "template_name") |
||||
|
: new ScriptParameterInfo(typeof(object), "value"); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,154 @@ |
|||||
|
using JetBrains.Annotations; |
||||
|
using Microsoft.Extensions.Localization; |
||||
|
using Scriban; |
||||
|
using Scriban.Runtime; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.Localization; |
||||
|
using Volo.Abp.TextTemplating; |
||||
|
|
||||
|
namespace LINGYUN.Abp.TextTemplating.Scriban; |
||||
|
public class ScribanTemplateRenderingEngine : TemplateRenderingEngineBase, ITransientDependency |
||||
|
{ |
||||
|
public const string EngineName = "Scriban"; |
||||
|
public override string Name => EngineName; |
||||
|
|
||||
|
public ScribanTemplateRenderingEngine( |
||||
|
ITemplateDefinitionManager templateDefinitionManager, |
||||
|
ITemplateContentProvider templateContentProvider, |
||||
|
IStringLocalizerFactory stringLocalizerFactory) |
||||
|
: base(templateDefinitionManager, templateContentProvider, stringLocalizerFactory) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public override async Task<string> RenderAsync( |
||||
|
[NotNull] string templateName, |
||||
|
object? model = null, |
||||
|
string? cultureName = null, |
||||
|
Dictionary<string, object>? globalContext = null) |
||||
|
{ |
||||
|
Check.NotNullOrWhiteSpace(templateName, nameof(templateName)); |
||||
|
|
||||
|
if (globalContext == null) |
||||
|
{ |
||||
|
globalContext = new Dictionary<string, object>(); |
||||
|
} |
||||
|
|
||||
|
if (cultureName == null) |
||||
|
{ |
||||
|
return await RenderInternalAsync( |
||||
|
templateName, |
||||
|
globalContext, |
||||
|
model |
||||
|
); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
using (CultureHelper.Use(cultureName)) |
||||
|
{ |
||||
|
return await RenderInternalAsync( |
||||
|
templateName, |
||||
|
globalContext, |
||||
|
model |
||||
|
); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
protected virtual async Task<string> RenderInternalAsync( |
||||
|
string templateName, |
||||
|
Dictionary<string, object> globalContext, |
||||
|
object? model = null) |
||||
|
{ |
||||
|
var templateDefinition = await TemplateDefinitionManager.GetAsync(templateName); |
||||
|
|
||||
|
var renderedContent = await RenderSingleTemplateAsync( |
||||
|
templateDefinition, |
||||
|
globalContext, |
||||
|
model |
||||
|
); |
||||
|
|
||||
|
if (templateDefinition.Layout != null) |
||||
|
{ |
||||
|
globalContext["content"] = renderedContent; |
||||
|
renderedContent = await RenderInternalAsync( |
||||
|
templateDefinition.Layout, |
||||
|
globalContext |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
return renderedContent; |
||||
|
} |
||||
|
|
||||
|
protected virtual async Task<string> RenderSingleTemplateAsync( |
||||
|
TemplateDefinition templateDefinition, |
||||
|
Dictionary<string, object> globalContext, |
||||
|
object? model = null) |
||||
|
{ |
||||
|
var rawTemplateContent = await GetContentOrNullAsync(templateDefinition); |
||||
|
|
||||
|
return await RenderTemplateContentWithScribanAsync( |
||||
|
templateDefinition, |
||||
|
rawTemplateContent!, |
||||
|
globalContext, |
||||
|
model |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
protected virtual async Task<string> RenderTemplateContentWithScribanAsync( |
||||
|
TemplateDefinition templateDefinition, |
||||
|
string templateContent, |
||||
|
Dictionary<string, object> globalContext, |
||||
|
object? model = null) |
||||
|
{ |
||||
|
var context = await CreateScribanTemplateContextAsync( |
||||
|
templateDefinition, |
||||
|
globalContext, |
||||
|
model |
||||
|
); |
||||
|
|
||||
|
return await Template |
||||
|
.Parse(templateContent) |
||||
|
.RenderAsync(context); |
||||
|
} |
||||
|
|
||||
|
protected async virtual Task<TemplateContext> CreateScribanTemplateContextAsync( |
||||
|
TemplateDefinition templateDefinition, |
||||
|
Dictionary<string, object> globalContext, |
||||
|
object? model = null) |
||||
|
{ |
||||
|
var context = new TemplateContext(); |
||||
|
|
||||
|
var scriptObject = new ScriptObject(); |
||||
|
|
||||
|
scriptObject.Import(globalContext); |
||||
|
|
||||
|
if (model != null) |
||||
|
{ |
||||
|
scriptObject["model"] = model; |
||||
|
} |
||||
|
|
||||
|
var localizer = await GetLocalizerOrNullAsync(templateDefinition); |
||||
|
if (localizer != null) |
||||
|
{ |
||||
|
scriptObject.SetValue("L", new ScribanTemplateLocalizer(localizer), true); |
||||
|
} |
||||
|
|
||||
|
context.PushGlobal(scriptObject); |
||||
|
context.PushCulture(System.Globalization.CultureInfo.CurrentCulture); |
||||
|
|
||||
|
return context; |
||||
|
} |
||||
|
|
||||
|
protected async virtual Task<IStringLocalizer?> GetLocalizerOrNullAsync(TemplateDefinition templateDefinition) |
||||
|
{ |
||||
|
if (templateDefinition.LocalizationResourceName != null) |
||||
|
{ |
||||
|
return await StringLocalizerFactory.CreateByResourceNameOrNullAsync(templateDefinition.LocalizationResourceName); |
||||
|
} |
||||
|
|
||||
|
return StringLocalizerFactory.CreateDefaultOrNull(); |
||||
|
} |
||||
|
} |
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue