Browse Source

CmsKit Tags Scheme Update

pull/6821/head
enisn 6 years ago
parent
commit
a80aeb940a
  1. 6
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/EntityTag.cs
  2. 7
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/ITagRepository.cs
  3. 4
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs
  4. 31
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreTagRepository.cs
  5. 6
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoTagRepository.cs

6
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/EntityTag.cs

@ -8,7 +8,7 @@ namespace Volo.CmsKit.Tags
{ {
public virtual Guid TagId { get; set; } public virtual Guid TagId { get; set; }
public virtual Guid EntityId { get; set; } public virtual string EntityId { get; set; }
public virtual Guid? TenantId { get; } public virtual Guid? TenantId { get; }
@ -16,7 +16,7 @@ namespace Volo.CmsKit.Tags
{ {
} }
public EntityTag(Guid tagId, Guid entityId, Guid? tenantId = null) public EntityTag(Guid tagId, string entityId, Guid? tenantId = null)
{ {
TagId = tagId; TagId = tagId;
EntityId = entityId; EntityId = entityId;
@ -25,7 +25,7 @@ namespace Volo.CmsKit.Tags
public override object[] GetKeys() public override object[] GetKeys()
{ {
return new object[] { TagId, EntityId, TenantId }; return new object[] { TagId, EntityId };
} }
} }

7
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/ITagRepository.cs

@ -1,5 +1,6 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using System; using System;
using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
@ -25,5 +26,11 @@ namespace Volo.CmsKit.Tags
[NotNull] string name, [NotNull] string name,
Guid? tenantId, Guid? tenantId,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
Task<List<Tag>> GetAllRelatedTagsAsync(
[NotNull] string entityType,
[NotNull] string entityId,
Guid? tenantId = null,
CancellationToken cancellationToken = default);
} }
} }

4
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs

@ -117,7 +117,7 @@ namespace Volo.CmsKit.EntityFrameworkCore
b.Property(x => x.EntityType).IsRequired().HasMaxLength(TagConsts.MaxEntityTypeLength); b.Property(x => x.EntityType).IsRequired().HasMaxLength(TagConsts.MaxEntityTypeLength);
b.Property(x => x.Name).IsRequired().HasMaxLength(TagConsts.MaxNameLength); b.Property(x => x.Name).IsRequired().HasMaxLength(TagConsts.MaxNameLength);
b.Property(x => x.HexColor).IsRequired().HasMaxLength(TagConsts.MaxColorHexLength); b.Property(x => x.HexColor).HasMaxLength(TagConsts.MaxColorHexLength);
b.HasIndex(x => new { x.TenantId, x.Name }); b.HasIndex(x => new { x.TenantId, x.Name });
}); });
@ -128,7 +128,7 @@ namespace Volo.CmsKit.EntityFrameworkCore
b.ConfigureByConvention(); b.ConfigureByConvention();
b.HasKey(x => new { x.TenantId, x.EntityId, x.TagId }); b.HasKey(x => new { x.EntityId, x.TagId });
b.Property(x => x.EntityId).IsRequired(); b.Property(x => x.EntityId).IsRequired();
b.Property(x => x.TagId).IsRequired(); b.Property(x => x.TagId).IsRequired();

31
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreTagRepository.cs

@ -1,11 +1,14 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.VirtualFileSystem;
using Volo.CmsKit.EntityFrameworkCore; using Volo.CmsKit.EntityFrameworkCore;
namespace Volo.CmsKit.Tags namespace Volo.CmsKit.Tags
@ -16,7 +19,7 @@ namespace Volo.CmsKit.Tags
{ {
} }
public Task<bool> AnyAsync( public virtual Task<bool> AnyAsync(
[NotNull] string entityType, [NotNull] string entityType,
[NotNull] string name, [NotNull] string name,
Guid? tenantId, Guid? tenantId,
@ -29,7 +32,7 @@ namespace Volo.CmsKit.Tags
cancellationToken); cancellationToken);
} }
public Task<Tag> GetAsync( public virtual Task<Tag> GetAsync(
[NotNull] string entityType, [NotNull] string entityType,
[NotNull] string name, [NotNull] string name,
Guid? tenantId, Guid? tenantId,
@ -42,7 +45,7 @@ namespace Volo.CmsKit.Tags
cancellationToken: cancellationToken); cancellationToken: cancellationToken);
} }
public Task<Tag> FindAsync( public virtual Task<Tag> FindAsync(
[NotNull] string entityType, [NotNull] string entityType,
[NotNull] string name, [NotNull] string name,
Guid? tenantId, Guid? tenantId,
@ -54,5 +57,27 @@ namespace Volo.CmsKit.Tags
x.TenantId == tenantId, x.TenantId == tenantId,
cancellationToken: cancellationToken); cancellationToken: cancellationToken);
} }
public virtual async Task<List<Tag>> GetAllRelatedTagsAsync(
[NotNull] string entityType,
[NotNull] string entityId,
Guid? tenantId = null,
CancellationToken cancellationToken = default)
{
var query = DbContext.Set<EntityTag>()
.Where(x =>
x.EntityId == entityId &&
x.TenantId == tenantId
)
.Join(
DbSet,
o => o.TagId,
i => i.Id,
(entityTag, tag) => tag)
.Where(x => x.EntityType == entityType);
return await query.ToListAsync();
}
} }
} }

6
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoTagRepository.cs

@ -1,6 +1,7 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using MongoDB.Driver.Linq; using MongoDB.Driver.Linq;
using System; using System;
using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories.MongoDB; using Volo.Abp.Domain.Repositories.MongoDB;
@ -54,5 +55,10 @@ namespace Volo.CmsKit.MongoDB.Tags
x.TenantId == tenantId, x.TenantId == tenantId,
cancellationToken: cancellationToken); cancellationToken: cancellationToken);
} }
public Task<List<Tag>> GetAllRelatedTagsAsync([NotNull] string entityType, [NotNull] string entityId, Guid? tenantId = null, CancellationToken cancellationToken = default)
{
throw new NotImplementedException();
}
} }
} }

Loading…
Cancel
Save