|
|
@ -5,6 +5,7 @@ using MongoDB.Driver; |
|
|
using MongoDB.Driver.Linq; |
|
|
using MongoDB.Driver.Linq; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
using System.Linq.Dynamic.Core; |
|
|
using System.Linq.Dynamic.Core; |
|
|
|
|
|
using System.Threading; |
|
|
using Volo.Abp.Domain.Repositories.MongoDB; |
|
|
using Volo.Abp.Domain.Repositories.MongoDB; |
|
|
using Volo.Abp.MongoDB; |
|
|
using Volo.Abp.MongoDB; |
|
|
|
|
|
|
|
|
@ -16,23 +17,31 @@ namespace Volo.Abp.Identity.MongoDB |
|
|
{ |
|
|
{ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public virtual async Task<bool> AnyAsync(string name, Guid? ignoredId = null) |
|
|
public virtual async Task<bool> AnyAsync( |
|
|
|
|
|
string name, |
|
|
|
|
|
Guid? ignoredId = null, |
|
|
|
|
|
CancellationToken cancellationToken = default) |
|
|
{ |
|
|
{ |
|
|
if (ignoredId == null) |
|
|
if (ignoredId == null) |
|
|
{ |
|
|
{ |
|
|
return await GetMongoQueryable() |
|
|
return await GetMongoQueryable() |
|
|
.Where(ct => ct.Name == name) |
|
|
.Where(ct => ct.Name == name) |
|
|
.AnyAsync(); |
|
|
.AnyAsync(GetCancellationToken(cancellationToken)); |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
return await GetMongoQueryable() |
|
|
return await GetMongoQueryable() |
|
|
.Where(ct => ct.Id != ignoredId && ct.Name == name) |
|
|
.Where(ct => ct.Id != ignoredId && ct.Name == name) |
|
|
.AnyAsync(); |
|
|
.AnyAsync(GetCancellationToken(cancellationToken)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public virtual async Task<List<IdentityClaimType>> GetListAsync(string sorting, int maxResultCount, int skipCount, string filter) |
|
|
public virtual async Task<List<IdentityClaimType>> GetListAsync( |
|
|
|
|
|
string sorting, |
|
|
|
|
|
int maxResultCount, |
|
|
|
|
|
int skipCount, |
|
|
|
|
|
string filter, |
|
|
|
|
|
CancellationToken cancellationToken = default) |
|
|
{ |
|
|
{ |
|
|
return await GetMongoQueryable() |
|
|
return await GetMongoQueryable() |
|
|
.WhereIf<IdentityClaimType, IMongoQueryable<IdentityClaimType>>( |
|
|
.WhereIf<IdentityClaimType, IMongoQueryable<IdentityClaimType>>( |
|
|
@ -43,7 +52,21 @@ namespace Volo.Abp.Identity.MongoDB |
|
|
.OrderBy(sorting ?? nameof(IdentityClaimType.Name)) |
|
|
.OrderBy(sorting ?? nameof(IdentityClaimType.Name)) |
|
|
.As<IMongoQueryable<IdentityClaimType>>() |
|
|
.As<IMongoQueryable<IdentityClaimType>>() |
|
|
.PageBy<IdentityClaimType, IMongoQueryable<IdentityClaimType>>(skipCount, maxResultCount) |
|
|
.PageBy<IdentityClaimType, IMongoQueryable<IdentityClaimType>>(skipCount, maxResultCount) |
|
|
.ToListAsync(); |
|
|
.ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async Task<long> GetCountAsync( |
|
|
|
|
|
string filter = null, |
|
|
|
|
|
CancellationToken cancellationToken = default) |
|
|
|
|
|
{ |
|
|
|
|
|
return await GetMongoQueryable() |
|
|
|
|
|
.WhereIf<IdentityClaimType, IMongoQueryable<IdentityClaimType>>( |
|
|
|
|
|
!filter.IsNullOrWhiteSpace(), |
|
|
|
|
|
u => |
|
|
|
|
|
u.Name.Contains(filter) |
|
|
|
|
|
) |
|
|
|
|
|
.As<IMongoQueryable<IdentityClaimType>>() |
|
|
|
|
|
.LongCountAsync(GetCancellationToken(cancellationToken)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|