|
|
|
@ -22,7 +22,6 @@ namespace Volo.CmsKit.MongoDB.Tags |
|
|
|
public async Task<bool> AnyAsync( |
|
|
|
[NotNull] string entityType, |
|
|
|
[NotNull] string name, |
|
|
|
Guid? tenantId = null, |
|
|
|
CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
Check.NotNullOrEmpty(entityType, nameof(entityType)); |
|
|
|
@ -31,28 +30,24 @@ namespace Volo.CmsKit.MongoDB.Tags |
|
|
|
return await (await GetMongoQueryableAsync(cancellationToken)) |
|
|
|
.AnyAsync(x => |
|
|
|
x.EntityType == entityType && |
|
|
|
x.Name == name && |
|
|
|
x.TenantId == tenantId, |
|
|
|
x.Name == name, |
|
|
|
GetCancellationToken(cancellationToken)); |
|
|
|
} |
|
|
|
|
|
|
|
public Task<Tag> GetAsync( |
|
|
|
[NotNull] string entityType, |
|
|
|
[NotNull] string name, |
|
|
|
Guid? tenantId = null, |
|
|
|
CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
return GetAsync(x => |
|
|
|
x.EntityType == entityType && |
|
|
|
x.Name == name && |
|
|
|
x.TenantId == tenantId, |
|
|
|
x.Name == name, |
|
|
|
cancellationToken: GetCancellationToken(cancellationToken)); |
|
|
|
} |
|
|
|
|
|
|
|
public Task<Tag> FindAsync( |
|
|
|
[NotNull] string entityType, |
|
|
|
[NotNull] string name, |
|
|
|
Guid? tenantId = null, |
|
|
|
CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
Check.NotNullOrEmpty(entityType, nameof(entityType)); |
|
|
|
@ -60,29 +55,26 @@ namespace Volo.CmsKit.MongoDB.Tags |
|
|
|
|
|
|
|
return FindAsync(x => |
|
|
|
x.EntityType == entityType && |
|
|
|
x.Name == name && |
|
|
|
x.TenantId == tenantId, |
|
|
|
x.Name == name, |
|
|
|
cancellationToken: GetCancellationToken(cancellationToken)); |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task<List<Tag>> GetAllRelatedTagsAsync( |
|
|
|
[NotNull] string entityType, |
|
|
|
[NotNull] string entityId, |
|
|
|
Guid? tenantId = null, |
|
|
|
CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
Check.NotNullOrEmpty(entityType, nameof(entityType)); |
|
|
|
Check.NotNullOrEmpty(entityId, nameof(entityId)); |
|
|
|
|
|
|
|
var entityTagIds = await (await GetDbContextAsync(cancellationToken)).EntityTags.AsQueryable() |
|
|
|
.Where(q => q.EntityId == entityId && q.TenantId == tenantId) |
|
|
|
.Where(q => q.EntityId == entityId) |
|
|
|
.Select(q => q.TagId) |
|
|
|
.ToListAsync(cancellationToken: GetCancellationToken(cancellationToken)); |
|
|
|
|
|
|
|
var query = (await GetMongoQueryableAsync(cancellationToken)) |
|
|
|
.Where(x => |
|
|
|
x.EntityType == entityType && |
|
|
|
x.TenantId == tenantId && |
|
|
|
entityTagIds.Contains(x.Id)); |
|
|
|
|
|
|
|
var result = await query.ToListAsync(cancellationToken: GetCancellationToken(cancellationToken)); |
|
|
|
|