CmsKit Tags Scheme Update

pull/6821/head
enisn 5 years ago
parent 81a0f166f4
commit a80aeb940a

@ -8,7 +8,7 @@ namespace Volo.CmsKit.Tags
{
public virtual Guid TagId { get; set; }
public virtual Guid EntityId { get; set; }
public virtual string EntityId { get; set; }
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;
EntityId = entityId;
@ -25,7 +25,7 @@ namespace Volo.CmsKit.Tags
public override object[] GetKeys()
{
return new object[] { TagId, EntityId, TenantId };
return new object[] { TagId, EntityId };
}
}

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

@ -117,7 +117,7 @@ namespace Volo.CmsKit.EntityFrameworkCore
b.Property(x => x.EntityType).IsRequired().HasMaxLength(TagConsts.MaxEntityTypeLength);
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 });
});
@ -128,7 +128,7 @@ namespace Volo.CmsKit.EntityFrameworkCore
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.TagId).IsRequired();

@ -1,11 +1,14 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.VirtualFileSystem;
using Volo.CmsKit.EntityFrameworkCore;
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 name,
Guid? tenantId,
@ -29,7 +32,7 @@ namespace Volo.CmsKit.Tags
cancellationToken);
}
public Task<Tag> GetAsync(
public virtual Task<Tag> GetAsync(
[NotNull] string entityType,
[NotNull] string name,
Guid? tenantId,
@ -42,7 +45,7 @@ namespace Volo.CmsKit.Tags
cancellationToken: cancellationToken);
}
public Task<Tag> FindAsync(
public virtual Task<Tag> FindAsync(
[NotNull] string entityType,
[NotNull] string name,
Guid? tenantId,
@ -54,5 +57,27 @@ namespace Volo.CmsKit.Tags
x.TenantId == tenantId,
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();
}
}
}

@ -1,6 +1,7 @@
using JetBrains.Annotations;
using MongoDB.Driver.Linq;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories.MongoDB;
@ -54,5 +55,10 @@ namespace Volo.CmsKit.MongoDB.Tags
x.TenantId == tenantId,
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