Browse Source

Merge pull request #10425 from abpframework/EngincanV/identity-custom-filters

Identity: Add new filters to repository
pull/10436/head
albert 5 years ago
committed by GitHub
parent
commit
e0df2ce25b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentityUserRepository.cs
  2. 12
      modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs
  3. 12
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserRepository.cs

6
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentityUserRepository.cs

@ -58,6 +58,9 @@ namespace Volo.Abp.Identity
bool includeDetails = false, bool includeDetails = false,
Guid? roleId = null, Guid? roleId = null,
Guid? organizationUnitId = null, Guid? organizationUnitId = null,
string userName = null,
string phoneNumber = null,
string emailAddress = null,
CancellationToken cancellationToken = default CancellationToken cancellationToken = default
); );
@ -90,6 +93,9 @@ namespace Volo.Abp.Identity
string filter = null, string filter = null,
Guid? roleId = null, Guid? roleId = null,
Guid? organizationUnitId = null, Guid? organizationUnitId = null,
string userName = null,
string phoneNumber = null,
string emailAddress = null,
CancellationToken cancellationToken = default CancellationToken cancellationToken = default
); );
} }

12
modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs

@ -138,6 +138,9 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
bool includeDetails = false, bool includeDetails = false,
Guid? roleId = null, Guid? roleId = null,
Guid? organizationUnitId = null, Guid? organizationUnitId = null,
string userName = null,
string phoneNumber = null,
string emailAddress = null,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
@ -153,6 +156,9 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
) )
.WhereIf(roleId.HasValue, identityUser => identityUser.Roles.Any(x => x.RoleId == roleId.Value)) .WhereIf(roleId.HasValue, identityUser => identityUser.Roles.Any(x => x.RoleId == roleId.Value))
.WhereIf(organizationUnitId.HasValue, identityUser => identityUser.OrganizationUnits.Any(x => x.OrganizationUnitId == organizationUnitId.Value)) .WhereIf(organizationUnitId.HasValue, identityUser => identityUser.OrganizationUnits.Any(x => x.OrganizationUnitId == organizationUnitId.Value))
.WhereIf(!string.IsNullOrWhiteSpace(userName), x => x.UserName == userName)
.WhereIf(!string.IsNullOrWhiteSpace(phoneNumber), x => x.PhoneNumber == phoneNumber)
.WhereIf(!string.IsNullOrWhiteSpace(emailAddress), x => x.Email == emailAddress)
.OrderBy(sorting.IsNullOrWhiteSpace() ? nameof(IdentityUser.UserName) : sorting) .OrderBy(sorting.IsNullOrWhiteSpace() ? nameof(IdentityUser.UserName) : sorting)
.PageBy(skipCount, maxResultCount) .PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
@ -193,6 +199,9 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
string filter = null, string filter = null,
Guid? roleId = null, Guid? roleId = null,
Guid? organizationUnitId = null, Guid? organizationUnitId = null,
string userName = null,
string phoneNumber = null,
string emailAddress = null,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
@ -207,6 +216,9 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
) )
.WhereIf(roleId.HasValue, identityUser => identityUser.Roles.Any(x => x.RoleId == roleId.Value)) .WhereIf(roleId.HasValue, identityUser => identityUser.Roles.Any(x => x.RoleId == roleId.Value))
.WhereIf(organizationUnitId.HasValue, identityUser => identityUser.OrganizationUnits.Any(x => x.OrganizationUnitId == organizationUnitId.Value)) .WhereIf(organizationUnitId.HasValue, identityUser => identityUser.OrganizationUnits.Any(x => x.OrganizationUnitId == organizationUnitId.Value))
.WhereIf(!string.IsNullOrWhiteSpace(userName), x => x.UserName == userName)
.WhereIf(!string.IsNullOrWhiteSpace(phoneNumber), x => x.PhoneNumber == phoneNumber)
.WhereIf(!string.IsNullOrWhiteSpace(emailAddress), x => x.Email == emailAddress)
.LongCountAsync(GetCancellationToken(cancellationToken)); .LongCountAsync(GetCancellationToken(cancellationToken));
} }

12
modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserRepository.cs

@ -140,6 +140,9 @@ namespace Volo.Abp.Identity.MongoDB
bool includeDetails = false, bool includeDetails = false,
Guid? roleId = null, Guid? roleId = null,
Guid? organizationUnitId = null, Guid? organizationUnitId = null,
string userName = null,
string phoneNumber = null,
string emailAddress = null,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
@ -154,6 +157,9 @@ namespace Volo.Abp.Identity.MongoDB
) )
.WhereIf<IdentityUser, IMongoQueryable<IdentityUser>>(roleId.HasValue, identityUser => identityUser.Roles.Any(x => x.RoleId == roleId.Value)) .WhereIf<IdentityUser, IMongoQueryable<IdentityUser>>(roleId.HasValue, identityUser => identityUser.Roles.Any(x => x.RoleId == roleId.Value))
.WhereIf<IdentityUser, IMongoQueryable<IdentityUser>>(organizationUnitId.HasValue, identityUser => identityUser.OrganizationUnits.Any(x => x.OrganizationUnitId == organizationUnitId.Value)) .WhereIf<IdentityUser, IMongoQueryable<IdentityUser>>(organizationUnitId.HasValue, identityUser => identityUser.OrganizationUnits.Any(x => x.OrganizationUnitId == organizationUnitId.Value))
.WhereIf<IdentityUser, IMongoQueryable<IdentityUser>>(!string.IsNullOrWhiteSpace(userName), x => x.UserName == userName)
.WhereIf<IdentityUser, IMongoQueryable<IdentityUser>>(!string.IsNullOrWhiteSpace(phoneNumber), x => x.PhoneNumber == phoneNumber)
.WhereIf<IdentityUser, IMongoQueryable<IdentityUser>>(!string.IsNullOrWhiteSpace(emailAddress), x => x.Email == emailAddress)
.OrderBy(sorting.IsNullOrWhiteSpace() ? nameof(IdentityUser.UserName) : sorting) .OrderBy(sorting.IsNullOrWhiteSpace() ? nameof(IdentityUser.UserName) : sorting)
.As<IMongoQueryable<IdentityUser>>() .As<IMongoQueryable<IdentityUser>>()
.PageBy<IdentityUser, IMongoQueryable<IdentityUser>>(skipCount, maxResultCount) .PageBy<IdentityUser, IMongoQueryable<IdentityUser>>(skipCount, maxResultCount)
@ -201,6 +207,9 @@ namespace Volo.Abp.Identity.MongoDB
string filter = null, string filter = null,
Guid? roleId = null, Guid? roleId = null,
Guid? organizationUnitId = null, Guid? organizationUnitId = null,
string userName = null,
string phoneNumber = null,
string emailAddress = null,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
@ -215,6 +224,9 @@ namespace Volo.Abp.Identity.MongoDB
) )
.WhereIf<IdentityUser, IMongoQueryable<IdentityUser>>(roleId.HasValue, identityUser => identityUser.Roles.Any(x => x.RoleId == roleId.Value)) .WhereIf<IdentityUser, IMongoQueryable<IdentityUser>>(roleId.HasValue, identityUser => identityUser.Roles.Any(x => x.RoleId == roleId.Value))
.WhereIf<IdentityUser, IMongoQueryable<IdentityUser>>(organizationUnitId.HasValue, identityUser => identityUser.OrganizationUnits.Any(x => x.OrganizationUnitId == organizationUnitId.Value)) .WhereIf<IdentityUser, IMongoQueryable<IdentityUser>>(organizationUnitId.HasValue, identityUser => identityUser.OrganizationUnits.Any(x => x.OrganizationUnitId == organizationUnitId.Value))
.WhereIf<IdentityUser, IMongoQueryable<IdentityUser>>(!string.IsNullOrWhiteSpace(userName), x => x.UserName == userName)
.WhereIf<IdentityUser, IMongoQueryable<IdentityUser>>(!string.IsNullOrWhiteSpace(phoneNumber), x => x.PhoneNumber == phoneNumber)
.WhereIf<IdentityUser, IMongoQueryable<IdentityUser>>(!string.IsNullOrWhiteSpace(emailAddress), x => x.Email == emailAddress)
.LongCountAsync(GetCancellationToken(cancellationToken)); .LongCountAsync(GetCancellationToken(cancellationToken));
} }

Loading…
Cancel
Save