|
|
|
@ -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(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|