Browse Source

Add `GetListAsync` and `GetCountAsync`.

pull/12084/head
maliming 4 years ago
parent
commit
b75c90a649
No known key found for this signature in database GPG Key ID: 96224957E51C89E
  1. 1
      modules/openiddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo.Abp.OpenIddict.Domain.Shared.csproj
  2. 4
      modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/AbpOpenIddictStoreBase.cs
  3. 4
      modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Applications/IOpenIddictApplicationRepository.cs
  4. 4
      modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Scopes/IOpenIddictScopeRepository.cs
  5. 18
      modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Applications/EfCoreOpenIddictApplicationRepository.cs
  6. 22
      modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Scopes/EfCoreOpenIddictScopeRepository.cs
  7. 20
      modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Applications/MongoOpenIddictApplicationRepository.cs
  8. 24
      modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Scopes/MongoOpenIddictScopeRepository.cs

1
modules/openiddict/src/Volo.Abp.OpenIddict.Domain.Shared/Volo.Abp.OpenIddict.Domain.Shared.csproj

@ -16,6 +16,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="6.0.0" />
<PackageReference Include="OpenIddict.Abstractions" Version="3.1.1" />
</ItemGroup>
<ItemGroup>

4
modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/AbpOpenIddictStoreBase.cs

@ -39,9 +39,7 @@ public abstract class AbpOpenIddictStoreBase<TRepository>
{
return identifier.ToString("D");
}
protected virtual string WriteStream(Action<Utf8JsonWriter> action)
{
using (var stream = new MemoryStream())

4
modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Applications/IOpenIddictApplicationRepository.cs

@ -8,6 +8,10 @@ namespace Volo.Abp.OpenIddict.Applications;
public interface IOpenIddictApplicationRepository : IBasicRepository<OpenIddictApplication, Guid>
{
Task<List<OpenIddictApplication>> GetListAsync(string sorting, int skipCount, int maxResultCount, string filter = null, CancellationToken cancellationToken = default);
Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default);
Task<OpenIddictApplication> FindByClientIdAsync(string clientId, CancellationToken cancellationToken = default);
Task<List<OpenIddictApplication>> FindByPostLogoutRedirectUriAsync(string address, CancellationToken cancellationToken = default);

4
modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Scopes/IOpenIddictScopeRepository.cs

@ -8,6 +8,10 @@ namespace Volo.Abp.OpenIddict.Scopes;
public interface IOpenIddictScopeRepository : IBasicRepository<OpenIddictScope, Guid>
{
Task<List<OpenIddictScope>> GetListAsync(string sorting, int skipCount, int maxResultCount, string filter = null, CancellationToken cancellationToken = default);
Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default);
Task<OpenIddictScope> FindByIdAsync(Guid id, CancellationToken cancellationToken = default);
Task<OpenIddictScope> FindByNameAsync(string name, CancellationToken cancellationToken = default);

18
modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Applications/EfCoreOpenIddictApplicationRepository.cs

@ -7,6 +7,7 @@ using Microsoft.EntityFrameworkCore;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.OpenIddict.EntityFrameworkCore;
using System.Linq.Dynamic.Core;
namespace Volo.Abp.OpenIddict.Applications;
@ -18,6 +19,23 @@ public class EfCoreOpenIddictApplicationRepository : EfCoreRepository<IOpenIddic
}
public async Task<List<OpenIddictApplication>> GetListAsync(string sorting, int skipCount, int maxResultCount, string filter = null,
CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.ClientId.Contains(filter))
.OrderBy(sorting.IsNullOrWhiteSpace() ? nameof(OpenIddictApplication.ClientId) : sorting)
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.ClientId.Contains(filter))
.LongCountAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<OpenIddictApplication> FindByClientIdAsync(string clientId, CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())

22
modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Scopes/EfCoreOpenIddictScopeRepository.cs

@ -7,6 +7,7 @@ using Microsoft.EntityFrameworkCore;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.OpenIddict.EntityFrameworkCore;
using System.Linq.Dynamic.Core;
namespace Volo.Abp.OpenIddict.Scopes;
@ -18,6 +19,27 @@ public class EfCoreOpenIddictScopeRepository : EfCoreRepository<IOpenIddictDbCon
}
public async Task<List<OpenIddictScope>> GetListAsync(string sorting, int skipCount, int maxResultCount, string filter = null,
CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Name.Contains(filter))
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.DisplayName.Contains(filter))
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Description.Contains(filter))
.OrderBy(sorting.IsNullOrWhiteSpace() ? nameof(OpenIddictScope.Name) : sorting)
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Name.Contains(filter))
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.DisplayName.Contains(filter))
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Description.Contains(filter))
.LongCountAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<OpenIddictScope> FindByIdAsync(Guid id, CancellationToken cancellationToken = default)
{
return await (await GetQueryableAsync()).FirstOrDefaultAsync(x => x.Id == id, GetCancellationToken(cancellationToken));

20
modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Applications/MongoOpenIddictApplicationRepository.cs

@ -8,6 +8,7 @@ using MongoDB.Driver.Linq;
using Volo.Abp.Domain.Repositories.MongoDB;
using Volo.Abp.MongoDB;
using Volo.Abp.OpenIddict.MongoDB;
using System.Linq.Dynamic.Core;
namespace Volo.Abp.OpenIddict.Applications;
@ -16,6 +17,25 @@ public class MongoOpenIddictApplicationRepository : MongoDbRepository<OpenIddict
public MongoOpenIddictApplicationRepository(IMongoDbContextProvider<OpenIddictMongoDbContext> dbContextProvider) : base(dbContextProvider)
{
}
public async Task<List<OpenIddictApplication>> GetListAsync(string sorting, int skipCount, int maxResultCount, string filter = null,
CancellationToken cancellationToken = default)
{
return await ((await GetMongoQueryableAsync(cancellationToken)))
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.ClientId.Contains(filter))
.OrderBy(sorting.IsNullOrWhiteSpace() ? nameof(OpenIddictApplication.ClientId) : sorting)
.PageBy(skipCount, maxResultCount)
.As<IMongoQueryable<OpenIddictApplication>>()
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{
return await ((await GetMongoQueryableAsync(cancellationToken)))
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.ClientId.Contains(filter))
.As<IMongoQueryable<OpenIddictApplication>>()
.LongCountAsync(GetCancellationToken(cancellationToken));
}
public async Task<OpenIddictApplication> FindByClientIdAsync(string clientId, CancellationToken cancellationToken = default)
{

24
modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Scopes/MongoOpenIddictScopeRepository.cs

@ -8,6 +8,7 @@ using MongoDB.Driver.Linq;
using Volo.Abp.Domain.Repositories.MongoDB;
using Volo.Abp.MongoDB;
using Volo.Abp.OpenIddict.MongoDB;
using System.Linq.Dynamic.Core;
namespace Volo.Abp.OpenIddict.Scopes;
@ -16,6 +17,29 @@ public class MongoOpenIddictScopeRepository : MongoDbRepository<OpenIddictMongoD
public MongoOpenIddictScopeRepository(IMongoDbContextProvider<OpenIddictMongoDbContext> dbContextProvider) : base(dbContextProvider)
{
}
public async Task<List<OpenIddictScope>> GetListAsync(string sorting, int skipCount, int maxResultCount, string filter = null,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Name.Contains(filter))
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.DisplayName.Contains(filter))
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Description.Contains(filter))
.OrderBy(sorting.IsNullOrWhiteSpace() ? nameof(OpenIddictScope.Name) : sorting)
.PageBy(skipCount, maxResultCount)
.As<IMongoQueryable<OpenIddictScope>>()
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Name.Contains(filter))
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.DisplayName.Contains(filter))
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Description.Contains(filter))
.As<IMongoQueryable<OpenIddictScope>>()
.LongCountAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<OpenIddictScope> FindByIdAsync(Guid id, CancellationToken cancellationToken = default)
{

Loading…
Cancel
Save