Browse Source

Improve OU repo.

pull/3732/head
Halil İbrahim Kalkan 7 years ago
parent
commit
32012c3b71
  1. 3
      modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserCreateOrUpdateDtoBase.cs
  2. 2
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs
  3. 25
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/Organizations/IOrganizationUnitRepository.cs
  4. 6
      modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreOrganizationUnitRepository.cs
  5. 7
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoOrganizationUnitRepository.cs

3
modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserCreateOrUpdateDtoBase.cs

@ -31,8 +31,5 @@ namespace Volo.Abp.Identity
[CanBeNull]
public string[] RoleNames { get; set; }
[CanBeNull]
public Guid[] OrganizationUnits { get; set; }
}
}

2
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs

@ -198,7 +198,7 @@ namespace Volo.Abp.Identity
return await OrganizationUnitRepository.GetListAsync(
user.OrganizationUnits.Select(t => t.OrganizationUnitId),
CancellationToken
cancellationToken: CancellationToken
);
}

25
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/Organizations/IOrganizationUnitRepository.cs

@ -8,12 +8,29 @@ namespace Volo.Abp.Identity.Organizations
{
public interface IOrganizationUnitRepository : IBasicRepository<OrganizationUnit, Guid>
{
Task<List<OrganizationUnit>> GetChildrenAsync(Guid? parentId, CancellationToken cancellationToken = default);
Task<List<OrganizationUnit>> GetChildrenAsync(
Guid? parentId,
bool includeDetails = false,
CancellationToken cancellationToken = default
);
Task<List<OrganizationUnit>> GetAllChildrenWithParentCodeAsync(string code, Guid? parentId, CancellationToken cancellationToken = default);
Task<List<OrganizationUnit>> GetAllChildrenWithParentCodeAsync(
string code,
Guid? parentId,
bool includeDetails = false,
CancellationToken cancellationToken = default
);
Task<List<OrganizationUnit>> GetListAsync(IEnumerable<Guid> ids, CancellationToken cancellationToken = default);
Task<List<OrganizationUnit>> GetListAsync(
IEnumerable<Guid> ids,
bool includeDetails = false,
CancellationToken cancellationToken = default
);
Task<OrganizationUnit> GetOrganizationUnitAsync(string displayName, bool includeDetails = false, CancellationToken cancellationToken = default);
Task<OrganizationUnit> GetOrganizationUnitAsync(
string displayName,
bool includeDetails = false,
CancellationToken cancellationToken = default
);
}
}

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

@ -22,9 +22,11 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
public async Task<List<OrganizationUnit>> GetChildrenAsync(
Guid? parentId,
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await DbSet
.IncludeDetails(includeDetails)
.Where(x => x.ParentId == parentId)
.ToListAsync(GetCancellationToken(cancellationToken));
}
@ -32,18 +34,22 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
public async Task<List<OrganizationUnit>> GetAllChildrenWithParentCodeAsync(
string code,
Guid? parentId,
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await DbSet
.IncludeDetails(includeDetails)
.Where(ou => ou.Code.StartsWith(code) && ou.Id != parentId.Value)
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<List<OrganizationUnit>> GetListAsync(
IEnumerable<Guid> ids,
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await DbSet
.IncludeDetails(includeDetails)
.Where(t => ids.Contains(t.Id))
.ToListAsync(GetCancellationToken(cancellationToken));
}

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

@ -21,6 +21,7 @@ namespace Volo.Abp.Identity.MongoDB
public async Task<List<OrganizationUnit>> GetChildrenAsync(
Guid? parentId,
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await GetMongoQueryable()
@ -31,6 +32,7 @@ namespace Volo.Abp.Identity.MongoDB
public async Task<List<OrganizationUnit>> GetAllChildrenWithParentCodeAsync(
string code,
Guid? parentId,
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await GetMongoQueryable()
@ -38,7 +40,10 @@ namespace Volo.Abp.Identity.MongoDB
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<List<OrganizationUnit>> GetListAsync(IEnumerable<Guid> ids, CancellationToken cancellationToken = default)
public async Task<List<OrganizationUnit>> GetListAsync(
IEnumerable<Guid> ids,
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await GetMongoQueryable()
.Where(t => ids.Contains(t.Id))

Loading…
Cancel
Save