Browse Source

Add GetCountAsync method

pull/7134/head
liangshiwei 6 years ago
parent
commit
0543e19ed5
  1. 2
      modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs
  2. 5
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/IApiResourceRepository.cs
  3. 5
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiScopes/IApiScopeRepository.cs
  4. 5
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/IClientRepository.cs
  5. 5
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IIdentityResourceRepository.cs
  6. 10
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/ApiResources/ApiResourceRepository.cs
  7. 10
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/ApiScopes/ApiScopeRepository.cs
  8. 7
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/Clients/ClientRepository.cs
  9. 10
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/IdentityResources/IdentityResourceRepository.cs
  10. 9
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoApiResourceRepository.cs
  11. 10
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoApiScopeRepository.cs
  12. 8
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoClientRepository.cs
  13. 10
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoIdentityResourceRepository.cs

2
modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs

@ -40,7 +40,7 @@ namespace Volo.Abp.Identity
public virtual async Task<PagedResultDto<IdentityRoleDto>> GetListAsync(GetIdentityRolesInput input)
{
var list = await RoleRepository.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount, input.Filter);
var totalCount = await RoleRepository.GetCountAsync();
var totalCount = await RoleRepository.GetCountAsync(input.Filter);
return new PagedResultDto<IdentityRoleDto>(
totalCount,

5
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/IApiResourceRepository.cs

@ -35,6 +35,11 @@ namespace Volo.Abp.IdentityServer.ApiResources
CancellationToken cancellationToken = default
);
Task<long> GetCountAsync(
string filter = null,
CancellationToken cancellationToken = default
);
Task<bool> CheckNameExistAsync(
string name,
Guid? expectedId = null,

5
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiScopes/IApiScopeRepository.cs

@ -29,6 +29,11 @@ namespace Volo.Abp.IdentityServer.ApiScopes
CancellationToken cancellationToken = default
);
Task<long> GetCountAsync(
string filter = null,
CancellationToken cancellationToken = default
);
Task<bool> CheckNameExistAsync(
string name,
Guid? expectedId = null,

5
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/IClientRepository.cs

@ -24,6 +24,11 @@ namespace Volo.Abp.IdentityServer.Clients
CancellationToken cancellationToken = default
);
Task<long> GetCountAsync(
string filter = null,
CancellationToken cancellationToken = default
);
Task<List<string>> GetAllDistinctAllowedCorsOriginsAsync(CancellationToken cancellationToken = default);
Task<bool> CheckClientIdExistAsync(

5
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IIdentityResourceRepository.cs

@ -23,6 +23,11 @@ namespace Volo.Abp.IdentityServer.IdentityResources
CancellationToken cancellationToken = default
);
Task<long> GetCountAsync(
string filter = null,
CancellationToken cancellationToken = default
);
Task<IdentityResource> FindByNameAsync(
string name,
bool includeDetails = true,

10
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/ApiResources/ApiResourceRepository.cs

@ -68,6 +68,16 @@ namespace Volo.Abp.IdentityServer.ApiResources
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{
return await DbSet
.WhereIf(!filter.IsNullOrWhiteSpace(),
x => x.Name.Contains(filter) ||
x.Description.Contains(filter) ||
x.DisplayName.Contains(filter))
.LongCountAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<bool> CheckNameExistAsync(string name, Guid? expectedId = null, CancellationToken cancellationToken = default)
{
return await DbSet.AnyAsync(ar => ar.Id != expectedId && ar.Name == name, GetCancellationToken(cancellationToken));

10
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/ApiScopes/ApiScopeRepository.cs

@ -48,6 +48,16 @@ namespace Volo.Abp.IdentityServer.ApiScopes
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{
return await DbSet
.WhereIf(!filter.IsNullOrWhiteSpace(),
x => x.Name.Contains(filter) ||
x.Description.Contains(filter) ||
x.DisplayName.Contains(filter))
.LongCountAsync(GetCancellationToken(cancellationToken));
}
public async Task<bool> CheckNameExistAsync(string name, Guid? expectedId = null, CancellationToken cancellationToken = default)
{
return await DbSet.AnyAsync(x => x.Id != expectedId && x.Name == name, GetCancellationToken(cancellationToken));

7
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/Clients/ClientRepository.cs

@ -41,6 +41,13 @@ namespace Volo.Abp.IdentityServer.Clients
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{
return await DbSet
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.ClientId.Contains(filter))
.LongCountAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<List<string>> GetAllDistinctAllowedCorsOriginsAsync(CancellationToken cancellationToken = default)
{
return await DbContext.ClientCorsOrigins

10
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/IdentityResources/IdentityResourceRepository.cs

@ -49,6 +49,16 @@ namespace Volo.Abp.IdentityServer.IdentityResources
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{
return await DbSet
.WhereIf(!filter.IsNullOrWhiteSpace(),
x => x.Name.Contains(filter) ||
x.Description.Contains(filter) ||
x.DisplayName.Contains(filter))
.LongCountAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<IdentityResource> FindByNameAsync(
string name,
bool includeDetails = true,

9
modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoApiResourceRepository.cs

@ -57,9 +57,14 @@ namespace Volo.Abp.IdentityServer.MongoDB
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<long> GetTotalCount()
public async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{
return await GetCountAsync();
return await GetMongoQueryable()
.WhereIf<ApiResource, IMongoQueryable<ApiResource>>(!filter.IsNullOrWhiteSpace(),
x => x.Name.Contains(filter) ||
x.Description.Contains(filter) ||
x.DisplayName.Contains(filter))
.LongCountAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<bool> CheckNameExistAsync(string name, Guid? expectedId = null, CancellationToken cancellationToken = default)

10
modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoApiScopeRepository.cs

@ -53,6 +53,16 @@ namespace Volo.Abp.IdentityServer.MongoDB
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{
return await GetMongoQueryable()
.WhereIf<ApiScope, IMongoQueryable<ApiScope>>(!filter.IsNullOrWhiteSpace(),
x => x.Name.Contains(filter) ||
x.Description.Contains(filter) ||
x.DisplayName.Contains(filter))
.LongCountAsync(GetCancellationToken(cancellationToken));
}
public async Task<bool> CheckNameExistAsync(string name, Guid? expectedId = null, CancellationToken cancellationToken = default)
{
return await GetMongoQueryable().AnyAsync(x => x.Id != expectedId && x.Name == name, GetCancellationToken(cancellationToken));

8
modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoClientRepository.cs

@ -48,6 +48,14 @@ namespace Volo.Abp.IdentityServer.MongoDB
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{
return await GetMongoQueryable()
.WhereIf<Client, IMongoQueryable<Client>>(!filter.IsNullOrWhiteSpace(),
x => x.ClientId.Contains(filter))
.LongCountAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<List<string>> GetAllDistinctAllowedCorsOriginsAsync(
CancellationToken cancellationToken = default)
{

10
modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoIdentityResourceRepository.cs

@ -30,6 +30,16 @@ namespace Volo.Abp.IdentityServer.MongoDB
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{
return await GetMongoQueryable()
.WhereIf<IdentityResource, IMongoQueryable<IdentityResource>>(!filter.IsNullOrWhiteSpace(),
x => x.Name.Contains(filter) ||
x.Description.Contains(filter) ||
x.DisplayName.Contains(filter))
.LongCountAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<IdentityResource> FindByNameAsync(
string name,
bool includeDetails = true,

Loading…
Cancel
Save