diff --git a/framework/src/Volo.Abp.BlobStoring.Aliyun/Volo/Abp/BlobStoring/Aliyun/AliyunBlobProvider.cs b/framework/src/Volo.Abp.BlobStoring.Aliyun/Volo/Abp/BlobStoring/Aliyun/AliyunBlobProvider.cs index aa0fecaf09..d6c9303afd 100644 --- a/framework/src/Volo.Abp.BlobStoring.Aliyun/Volo/Abp/BlobStoring/Aliyun/AliyunBlobProvider.cs +++ b/framework/src/Volo.Abp.BlobStoring.Aliyun/Volo/Abp/BlobStoring/Aliyun/AliyunBlobProvider.cs @@ -37,7 +37,7 @@ namespace Volo.Abp.BlobStoring.Aliyun var blobName = AliyunBlobNameCalculator.Calculate(args); var aliyunConfig = args.Configuration.GetAliyunConfiguration(); var ossClient = GetOssClient(aliyunConfig); - if (!args.OverrideExisting && BlobExistsAsync(ossClient, containerName, blobName)) + if (!args.OverrideExisting && BlobExists(ossClient, containerName, blobName)) { throw new BlobAlreadyExistsException($"Saving BLOB '{args.BlobName}' does already exists in the container '{containerName}'! Set {nameof(args.OverrideExisting)} if it should be overwritten."); } @@ -57,7 +57,7 @@ namespace Volo.Abp.BlobStoring.Aliyun var containerName = GetContainerName(args); var blobName = AliyunBlobNameCalculator.Calculate(args); var ossClient = GetOssClient(args.Configuration); - if(!BlobExistsAsync(ossClient, containerName, blobName)) + if(!BlobExists(ossClient, containerName, blobName)) { return Task.FromResult(false); } @@ -70,7 +70,7 @@ namespace Volo.Abp.BlobStoring.Aliyun var containerName = GetContainerName(args); var blobName = AliyunBlobNameCalculator.Calculate(args); var ossClient = GetOssClient(args.Configuration); - return Task.FromResult(BlobExistsAsync(ossClient, containerName, blobName)); + return Task.FromResult(BlobExists(ossClient, containerName, blobName)); } public async override Task GetOrNullAsync(BlobProviderGetArgs args) @@ -78,7 +78,7 @@ namespace Volo.Abp.BlobStoring.Aliyun var containerName = GetContainerName(args); var blobName = AliyunBlobNameCalculator.Calculate(args); var ossClient = GetOssClient(args.Configuration); - if (!BlobExistsAsync(ossClient, containerName, blobName)) + if (!BlobExists(ossClient, containerName, blobName)) { return null; } @@ -96,7 +96,7 @@ namespace Volo.Abp.BlobStoring.Aliyun : configuration.ContainerName; } - private bool BlobExistsAsync(IOss ossClient,string containerName, string blobName) + private bool BlobExists(IOss ossClient,string containerName, string blobName) { // Make sure Blob Container exists. return ossClient.DoesBucketExist(containerName) && diff --git a/framework/src/Volo.Abp.BlobStoring.Aliyun/Volo/Abp/BlobStoring/Aliyun/AliyunBlobProviderConfiguration.cs b/framework/src/Volo.Abp.BlobStoring.Aliyun/Volo/Abp/BlobStoring/Aliyun/AliyunBlobProviderConfiguration.cs index 757ad4b54c..276cbd8fc7 100644 --- a/framework/src/Volo.Abp.BlobStoring.Aliyun/Volo/Abp/BlobStoring/Aliyun/AliyunBlobProviderConfiguration.cs +++ b/framework/src/Volo.Abp.BlobStoring.Aliyun/Volo/Abp/BlobStoring/Aliyun/AliyunBlobProviderConfiguration.cs @@ -81,7 +81,7 @@ namespace Volo.Abp.BlobStoring.Aliyun /// public string ContainerName { - get => _containerConfiguration.GetConfiguration(AliyunBlobProviderConfigurationNames.ContainerName); + get => _containerConfiguration.GetConfigurationOrDefault(AliyunBlobProviderConfigurationNames.ContainerName); set => _containerConfiguration.SetConfiguration(AliyunBlobProviderConfigurationNames.ContainerName, Check.NotNullOrWhiteSpace(value, nameof(value))); } diff --git a/framework/src/Volo.Abp.BlobStoring.Aws/Volo/Abp/BlobStoring/Aws/AwsBlobProviderConfiguration.cs b/framework/src/Volo.Abp.BlobStoring.Aws/Volo/Abp/BlobStoring/Aws/AwsBlobProviderConfiguration.cs index c2d3297f4e..2be373e428 100644 --- a/framework/src/Volo.Abp.BlobStoring.Aws/Volo/Abp/BlobStoring/Aws/AwsBlobProviderConfiguration.cs +++ b/framework/src/Volo.Abp.BlobStoring.Aws/Volo/Abp/BlobStoring/Aws/AwsBlobProviderConfiguration.cs @@ -81,7 +81,7 @@ namespace Volo.Abp.BlobStoring.Aws /// public string ContainerName { - get => _containerConfiguration.GetConfiguration(AwsBlobProviderConfigurationNames.ContainerName); + get => _containerConfiguration.GetConfigurationOrDefault(AwsBlobProviderConfigurationNames.ContainerName); set => _containerConfiguration.SetConfiguration(AwsBlobProviderConfigurationNames.ContainerName, Check.NotNullOrWhiteSpace(value, nameof(value))); } diff --git a/framework/src/Volo.Abp.BlobStoring.Azure/Volo/Abp/BlobStoring/Azure/AzureBlobProviderConfiguration.cs b/framework/src/Volo.Abp.BlobStoring.Azure/Volo/Abp/BlobStoring/Azure/AzureBlobProviderConfiguration.cs index 7ab338794b..969057d7d6 100644 --- a/framework/src/Volo.Abp.BlobStoring.Azure/Volo/Abp/BlobStoring/Azure/AzureBlobProviderConfiguration.cs +++ b/framework/src/Volo.Abp.BlobStoring.Azure/Volo/Abp/BlobStoring/Azure/AzureBlobProviderConfiguration.cs @@ -16,7 +16,7 @@ /// public string ContainerName { - get => _containerConfiguration.GetConfiguration(AzureBlobProviderConfigurationNames.ContainerName); + get => _containerConfiguration.GetConfigurationOrDefault(AzureBlobProviderConfigurationNames.ContainerName); set => _containerConfiguration.SetConfiguration(AzureBlobProviderConfigurationNames.ContainerName, Check.NotNullOrWhiteSpace(value, nameof(value))); } diff --git a/framework/src/Volo.Abp.BlobStoring.Minio/Volo/Abp/BlobStoring/Minio/MinioBlobProviderConfiguration.cs b/framework/src/Volo.Abp.BlobStoring.Minio/Volo/Abp/BlobStoring/Minio/MinioBlobProviderConfiguration.cs index 63b0132d20..395aa76a72 100644 --- a/framework/src/Volo.Abp.BlobStoring.Minio/Volo/Abp/BlobStoring/Minio/MinioBlobProviderConfiguration.cs +++ b/framework/src/Volo.Abp.BlobStoring.Minio/Volo/Abp/BlobStoring/Minio/MinioBlobProviderConfiguration.cs @@ -4,7 +4,7 @@ { public string BucketName { - get => _containerConfiguration.GetConfiguration(MinioBlobProviderConfigurationNames.BucketName); + get => _containerConfiguration.GetConfigurationOrDefault(MinioBlobProviderConfigurationNames.BucketName); set => _containerConfiguration.SetConfiguration(MinioBlobProviderConfigurationNames.BucketName, Check.NotNullOrWhiteSpace(value, nameof(value))); } @@ -42,7 +42,7 @@ { get => _containerConfiguration.GetConfigurationOrDefault(MinioBlobProviderConfigurationNames.WithSSL, false); set => _containerConfiguration.SetConfiguration(MinioBlobProviderConfigurationNames.WithSSL, value); - } + } /// ///Default value: false. diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/GlobalCmsKitFeatures.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/GlobalCmsKitFeatures.cs index db987784fd..5a7adc34b2 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/GlobalCmsKitFeatures.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/GlobalCmsKitFeatures.cs @@ -15,6 +15,10 @@ namespace Volo.CmsKit.GlobalFeatures public TagsFeature Tags => GetFeature(); + public ContentsFeature Contents => GetFeature(); + + public PagesFeature Pages => GetFeature(); + public GlobalCmsKitFeatures([NotNull] GlobalFeatureManager featureManager) : base(featureManager) { @@ -23,6 +27,7 @@ namespace Volo.CmsKit.GlobalFeatures AddFeature(new RatingsFeature(this)); AddFeature(new TagsFeature(this)); AddFeature(new ContentsFeature(this)); + AddFeature(new PagesFeature(this)); } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/PagesFeature.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/PagesFeature.cs new file mode 100644 index 0000000000..c41e217999 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/PagesFeature.cs @@ -0,0 +1,29 @@ +using JetBrains.Annotations; +using Volo.Abp.GlobalFeatures; + +namespace Volo.CmsKit.GlobalFeatures +{ + [GlobalFeatureName(Name)] + public class PagesFeature:GlobalFeature + { + public const string Name = "CmsKit.Pages"; + + internal PagesFeature( + [NotNull] GlobalCmsKitFeatures cmsKit + ) : base(cmsKit) + { + + } + + public override void Enable() + { + var contentsFeature = FeatureManager.Modules.CmsKit().Contents; + if (!contentsFeature.IsEnabled) + { + contentsFeature.Enable(); + } + + base.Enable(); + } + } +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoTagRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoTagRepository.cs index 5f57d835f5..de543d4666 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoTagRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoTagRepository.cs @@ -69,12 +69,11 @@ namespace Volo.CmsKit.MongoDB.Tags .Select(q => q.TagId) .ToListAsync(cancellationToken: GetCancellationToken(cancellationToken)); - var query = await Collection.FindAsync(Builders.Filter.And(new[] - { - Builders.Filter.Eq(x =>x.EntityType, entityType), - Builders.Filter.Eq(x =>x.TenantId, tenantId), - Builders.Filter.In(x => x.Id, entityTagIds), - })); + var query = GetMongoQueryable() + .Where(x => + x.EntityType == entityType && + x.TenantId == tenantId && + entityTagIds.Contains(x.Id)); var result = await query.ToListAsync(cancellationToken: GetCancellationToken(cancellationToken)); return result; diff --git a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Features/GlobalCmsKitFeatures_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Features/GlobalCmsKitFeatures_Tests.cs new file mode 100644 index 0000000000..97e53daeb8 --- /dev/null +++ b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Features/GlobalCmsKitFeatures_Tests.cs @@ -0,0 +1,30 @@ +using Shouldly; +using Volo.Abp.GlobalFeatures; +using Volo.CmsKit.GlobalFeatures; +using Xunit; + +namespace Volo.CmsKit.Features +{ + public class GlobalCmsKitFeatures_Tests : CmsKitDomainTestBase + { + private readonly GlobalCmsKitFeatures _cmsKitFeatures; + + public GlobalCmsKitFeatures_Tests() + { + _cmsKitFeatures = new GlobalCmsKitFeatures(GlobalFeatureManager.Instance); + } + + [Fact] + public void Page_Feature_Should_Enable_Dependent_Features() + { + _cmsKitFeatures.DisableAll(); + _cmsKitFeatures.Contents.IsEnabled.ShouldBeFalse(); + _cmsKitFeatures.Pages.IsEnabled.ShouldBeFalse(); + + _cmsKitFeatures.Pages.Enable(); + + _cmsKitFeatures.Contents.IsEnabled.ShouldBeTrue(); + _cmsKitFeatures.Pages.IsEnabled.ShouldBeTrue(); + } + } +} \ No newline at end of file