Browse Source

fixed parentId parameter and tested complete

pull/5292/head
向洪林 6 years ago
parent
commit
a6d7ff9594
  1. 1
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IOrganizationUnitRepository.cs
  2. 3
      modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreOrganizationUnitRepository.cs
  3. 3
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoOrganizationUnitRepository.cs
  4. 18
      modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/OrganizationUnitRepository_Tests.cs

1
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IOrganizationUnitRepository.cs

@ -28,6 +28,7 @@ namespace Volo.Abp.Identity
);
Task<List<OrganizationUnit>> GetListAsync(
Guid? parentId,
string sorting = null,
int maxResultCount = int.MaxValue,
int skipCount = 0,

3
modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreOrganizationUnitRepository.cs

@ -45,6 +45,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
}
public virtual async Task<List<OrganizationUnit>> GetListAsync(
Guid? parentId,
string sorting = null,
int maxResultCount = int.MaxValue,
int skipCount = 0,
@ -54,6 +55,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
{
return await DbSet
.IncludeDetails(includeDetails)
.Where(ou=>ou.ParentId==parentId)
.WhereIf(!filter.IsNullOrWhiteSpace(),
ou => ou.DisplayName.Contains(filter) ||
ou.Code.Contains(filter))
@ -172,6 +174,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
CancellationToken cancellationToken = default)
{
return await DbSet
.Where(ou=>ou.ParentId==parentId)
.WhereIf(!filter.IsNullOrWhiteSpace(), ou =>
ou.DisplayName.Contains(filter) ||
ou.Code.Contains(filter))

3
modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoOrganizationUnitRepository.cs

@ -56,6 +56,7 @@ namespace Volo.Abp.Identity.MongoDB
}
public virtual async Task<List<OrganizationUnit>> GetListAsync(
Guid? parentId,
string sorting = null,
int maxResultCount = int.MaxValue,
int skipCount = 0,
@ -64,6 +65,7 @@ namespace Volo.Abp.Identity.MongoDB
CancellationToken cancellationToken = default)
{
return await GetMongoQueryable()
.Where(ou=>ou.ParentId==parentId)
.WhereIf(!filter.IsNullOrWhiteSpace(),
ou => ou.DisplayName.Contains(filter) ||
ou.Code.Contains(filter))
@ -165,6 +167,7 @@ namespace Volo.Abp.Identity.MongoDB
CancellationToken cancellationToken = default)
{
return await GetMongoQueryable()
.Where(ou=>ou.ParentId==parentId)
.WhereIf<OrganizationUnit, IMongoQueryable<OrganizationUnit>>(!filter.IsNullOrWhiteSpace(), ou =>
ou.DisplayName.Contains(filter) ||
ou.Code.Contains(filter))

18
modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/OrganizationUnitRepository_Tests.cs

@ -59,6 +59,22 @@ namespace Volo.Abp.Identity
var ous = await _organizationUnitRepository.GetListAsync(ouIds);
ous.Count.ShouldBe(2);
ous.ShouldContain(ou => ou.Id == ouIds.First());
var ou11 = await _organizationUnitRepository.GetAsync("OU11");
ou11.ShouldNotBeNull();
var ou11Children = await _organizationUnitRepository.GetListAsync(ou11.Id, includeDetails: true);
ou11Children.Count.ShouldBe(2);
}
[Fact]
public async Task GetLongCountAsync()
{
(await _organizationUnitRepository.GetLongCountAsync(_guidGenerator.Create(), filter: "11")).ShouldBe(0);
var countRoot = await _organizationUnitRepository.GetLongCountAsync(null, filter: "1");
countRoot.ShouldBe(1);
var ou11 = await _organizationUnitRepository.GetAsync("OU11");
ou11.ShouldNotBeNull();
(await _organizationUnitRepository.GetLongCountAsync(ou11.Id, "2")).ShouldBe(1);
}
[Fact]
@ -192,7 +208,7 @@ namespace Volo.Abp.Identity
{
OrganizationUnit ou1 = await _organizationUnitRepository.GetAsync("OU111", true);
OrganizationUnit ou2 = await _organizationUnitRepository.GetAsync("OU112", true);
var users = await _identityUserRepository.GetUsersInOrganizationsListAsync(new List<Guid> {ou1.Id, ou2.Id});
var users = await _identityUserRepository.GetUsersInOrganizationsListAsync(new List<Guid> { ou1.Id, ou2.Id });
users.Count.ShouldBeGreaterThan(0);
}

Loading…
Cancel
Save