diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Contents/ContentAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Contents/ContentAdminAppService.cs index f83d77af52..4695339fd7 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Contents/ContentAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Contents/ContentAdminAppService.cs @@ -21,6 +21,7 @@ namespace Volo.CmsKit.Admin.Contents >, IContentAdminAppService { protected IContentManager ContentManager { get; } + protected IContentRepository ContentRepository { get; } public ContentAdminAppService( diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Contents/EfCoreContentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Contents/EfCoreContentRepository.cs index adbbd73dc8..884c5e9b01 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Contents/EfCoreContentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Contents/EfCoreContentRepository.cs @@ -22,7 +22,6 @@ namespace Volo.CmsKit.Contents CancellationToken cancellationToken = default) { return GetAsync(x => - !x.IsDeleted && x.EntityType == entityType && x.EntityId == entityId && x.TenantId == tenantId, @@ -37,7 +36,6 @@ namespace Volo.CmsKit.Contents CancellationToken cancellationToken = default) { return FindAsync(x => - !x.IsDeleted && x.EntityType == entityType && x.EntityId == entityId && x.TenantId == tenantId, diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs index ebcb5dc22e..3c937a3432 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs @@ -41,8 +41,8 @@ namespace Volo.CmsKit.EntityFrameworkCore b.ConfigureByConvention(); b.ConfigureAbpUser(); - b.HasIndex(x => new {x.TenantId, x.UserName}); - b.HasIndex(x => new {x.TenantId, x.Email}); + b.HasIndex(x => new { x.TenantId, x.UserName }); + b.HasIndex(x => new { x.TenantId, x.Email }); }); } @@ -93,61 +93,62 @@ namespace Volo.CmsKit.EntityFrameworkCore r.Property(x => x.EntityType).IsRequired().HasMaxLength(RatingConsts.MaxEntityTypeLength); r.Property(x => x.EntityId).IsRequired().HasMaxLength(RatingConsts.MaxEntityIdLength); - r.HasIndex(x => new {x.TenantId, x.EntityType, x.EntityId, x.CreatorId}); + r.HasIndex(x => new { x.TenantId, x.EntityType, x.EntityId, x.CreatorId }); }); } - builder.Entity(b => + if (GlobalFeatureManager.Instance.IsEnabled()) { - b.ToTable(options.TablePrefix + "Contents", options.Schema); + builder.Entity(b => + { + b.ToTable(options.TablePrefix + "Contents", options.Schema); - b.ConfigureByConvention(); + b.ConfigureByConvention(); - b.HasQueryFilter(x => !x.IsDeleted); // TODO: Find out why default filter doesn't work. + b.Property(x => x.EntityType).IsRequired().HasMaxLength(ContentConsts.MaxEntityTypeLength); + b.Property(x => x.EntityId).IsRequired().HasMaxLength(ContentConsts.MaxEntityIdLength); + b.Property(x => x.Value).IsRequired().HasMaxLength(ContentConsts.MaxValueLength); + + b.HasIndex(x => new { x.TenantId, x.EntityType, x.EntityId }); + }); + } - b.Property(x => x.EntityType).IsRequired().HasMaxLength(ContentConsts.MaxEntityTypeLength); - b.Property(x => x.EntityId).IsRequired().HasMaxLength(ContentConsts.MaxEntityIdLength); - b.Property(x => x.Value).IsRequired().HasMaxLength(ContentConsts.MaxValueLength); - - b.HasIndex(x => new { x.TenantId, x.EntityType, x.EntityId }); - }); - builder.Entity(b => { b.ToTable(options.TablePrefix + "Tags", options.Schema); - + b.ConfigureByConvention(); - + b.Property(x => x.EntityType).IsRequired().HasMaxLength(TagConsts.MaxEntityTypeLength); b.Property(x => x.Name).IsRequired().HasMaxLength(TagConsts.MaxNameLength); - + b.HasIndex(x => new { x.TenantId, x.Name }); }); - + builder.Entity(b => { b.ToTable(options.TablePrefix + "EntityTags", options.Schema); - + b.ConfigureByConvention(); b.HasKey(x => new { x.EntityId, x.TagId }); - + b.Property(x => x.EntityId).IsRequired(); b.Property(x => x.TagId).IsRequired(); - + b.HasIndex(x => new { x.TenantId, x.EntityId, x.TagId }); }); - + builder.Entity(b => { b.ToTable(options.TablePrefix + "Pages", options.Schema); - + b.ConfigureByConvention(); - + b.Property(x => x.Title).IsRequired().HasMaxLength(PageConsts.MaxTitleLength); b.Property(x => x.Url).IsRequired().HasMaxLength(PageConsts.MaxUrlLength); b.Property(x => x.Description).HasMaxLength(PageConsts.MaxDescriptionLength); - + b.HasIndex(x => new { x.TenantId, x.Url }); }); } diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Contents/MongoContentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Contents/MongoContentRepository.cs index 234757384f..f42b0890e7 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Contents/MongoContentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Contents/MongoContentRepository.cs @@ -22,7 +22,6 @@ namespace Volo.CmsKit.MongoDB.Contents CancellationToken cancellationToken = default) { return GetAsync(x => - !x.IsDeleted && x.EntityType == entityType && x.EntityId == entityId && x.TenantId == tenantId, @@ -37,7 +36,6 @@ namespace Volo.CmsKit.MongoDB.Contents CancellationToken cancellationToken = default) { return FindAsync(x => - !x.IsDeleted && x.EntityType == entityType && x.EntityId == entityId && x.TenantId == tenantId, @@ -57,7 +55,6 @@ namespace Volo.CmsKit.MongoDB.Contents public async Task ExistsAsync([NotNull] string entityType, [NotNull] string entityId, Guid? tenantId = null, CancellationToken cancellationToken = default) { return await (await GetMongoQueryableAsync()).AnyAsync(x => - !x.IsDeleted && x.EntityType == entityType && x.EntityId == entityId && x.TenantId == tenantId,