Browse Source

Merge pull request #21989 from abpframework/vs-internal-issue-#5807

Vs internal issue #5807
issue/assign-available-port-for-suite
oykuermann 2 years ago
committed by GitHub
parent
commit
a1745607ea
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentityUserRepository.cs
  2. 58
      modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs
  3. 15
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserRepository.cs

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

@ -69,6 +69,7 @@ public interface IIdentityUserRepository : IBasicRepository<IdentityUser, Guid>
bool includeDetails = false, bool includeDetails = false,
Guid? roleId = null, Guid? roleId = null,
Guid? organizationUnitId = null, Guid? organizationUnitId = null,
Guid? id = null,
string userName = null, string userName = null,
string phoneNumber = null, string phoneNumber = null,
string emailAddress = null, string emailAddress = null,
@ -114,6 +115,7 @@ public interface IIdentityUserRepository : IBasicRepository<IdentityUser, Guid>
string filter = null, string filter = null,
Guid? roleId = null, Guid? roleId = null,
Guid? organizationUnitId = null, Guid? organizationUnitId = null,
Guid? id = null,
string userName = null, string userName = null,
string phoneNumber = null, string phoneNumber = null,
string emailAddress = null, string emailAddress = null,

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

@ -62,35 +62,35 @@ public class EfCoreIdentityUserRepository : EfCoreRepository<IIdentityDbContext,
{ {
var dbContext = await GetDbContextAsync(); var dbContext = await GetDbContextAsync();
var userRoles = await (from userRole in dbContext.Set<IdentityUserRole>() var userRoles = await (from userRole in dbContext.Set<IdentityUserRole>()
join role in dbContext.Roles on userRole.RoleId equals role.Id join role in dbContext.Roles on userRole.RoleId equals role.Id
where userIds.Contains(userRole.UserId) where userIds.Contains(userRole.UserId)
group new group new {
{ userRole.UserId,
userRole.UserId, role.Name
role.Name } by userRole.UserId
} by userRole.UserId
into gp into gp
select new IdentityUserIdWithRoleNames select new IdentityUserIdWithRoleNames
{ {
Id = gp.Key, RoleNames = gp.Select(x => x.Name).ToArray() Id = gp.Key,
}).ToListAsync(cancellationToken: cancellationToken); RoleNames = gp.Select(x => x.Name).ToArray()
}).ToListAsync(cancellationToken: cancellationToken);
var orgUnitRoles = await (from userOu in dbContext.Set<IdentityUserOrganizationUnit>() var orgUnitRoles = await (from userOu in dbContext.Set<IdentityUserOrganizationUnit>()
join roleOu in dbContext.Set<OrganizationUnitRole>() on userOu.OrganizationUnitId equals roleOu.OrganizationUnitId join roleOu in dbContext.Set<OrganizationUnitRole>() on userOu.OrganizationUnitId equals roleOu.OrganizationUnitId
join role in dbContext.Roles on roleOu.RoleId equals role.Id join role in dbContext.Roles on roleOu.RoleId equals role.Id
where userIds.Contains(userOu.UserId) where userIds.Contains(userOu.UserId)
group new group new {
{ userOu.UserId,
userOu.UserId, role.Name
role.Name } by userOu.UserId
} by userOu.UserId
into gp into gp
select new IdentityUserIdWithRoleNames select new IdentityUserIdWithRoleNames
{ {
Id = gp.Key, RoleNames = gp.Select(x => x.Name).ToArray() Id = gp.Key,
}).ToListAsync(cancellationToken: cancellationToken); RoleNames = gp.Select(x => x.Name).ToArray()
}).ToListAsync(cancellationToken: cancellationToken);
return userRoles.Concat(orgUnitRoles).GroupBy(x => x.Id).Select(x => new IdentityUserIdWithRoleNames {Id = x.Key, RoleNames = x.SelectMany(y => y.RoleNames).Distinct().ToArray()}).ToList(); return userRoles.Concat(orgUnitRoles).GroupBy(x => x.Id).Select(x => new IdentityUserIdWithRoleNames { Id = x.Key, RoleNames = x.SelectMany(y => y.RoleNames).Distinct().ToArray() }).ToList();
} }
public virtual async Task<List<string>> GetRoleNamesInOrganizationUnitAsync( public virtual async Task<List<string>> GetRoleNamesInOrganizationUnitAsync(
@ -196,6 +196,7 @@ public class EfCoreIdentityUserRepository : EfCoreRepository<IIdentityDbContext,
bool includeDetails = false, bool includeDetails = false,
Guid? roleId = null, Guid? roleId = null,
Guid? organizationUnitId = null, Guid? organizationUnitId = null,
Guid? id = null,
string userName = null, string userName = null,
string phoneNumber = null, string phoneNumber = null,
string emailAddress = null, string emailAddress = null,
@ -215,6 +216,7 @@ public class EfCoreIdentityUserRepository : EfCoreRepository<IIdentityDbContext,
filter, filter,
roleId, roleId,
organizationUnitId, organizationUnitId,
id,
userName, userName,
phoneNumber, phoneNumber,
emailAddress, emailAddress,
@ -272,6 +274,7 @@ public class EfCoreIdentityUserRepository : EfCoreRepository<IIdentityDbContext,
string filter = null, string filter = null,
Guid? roleId = null, Guid? roleId = null,
Guid? organizationUnitId = null, Guid? organizationUnitId = null,
Guid? id = null,
string userName = null, string userName = null,
string phoneNumber = null, string phoneNumber = null,
string emailAddress = null, string emailAddress = null,
@ -291,6 +294,7 @@ public class EfCoreIdentityUserRepository : EfCoreRepository<IIdentityDbContext,
filter, filter,
roleId, roleId,
organizationUnitId, organizationUnitId,
id,
userName, userName,
phoneNumber, phoneNumber,
emailAddress, emailAddress,
@ -434,6 +438,7 @@ public class EfCoreIdentityUserRepository : EfCoreRepository<IIdentityDbContext,
string filter = null, string filter = null,
Guid? roleId = null, Guid? roleId = null,
Guid? organizationUnitId = null, Guid? organizationUnitId = null,
Guid? id = null,
string userName = null, string userName = null,
string phoneNumber = null, string phoneNumber = null,
string emailAddress = null, string emailAddress = null,
@ -451,6 +456,11 @@ public class EfCoreIdentityUserRepository : EfCoreRepository<IIdentityDbContext,
{ {
var upperFilter = filter?.ToUpperInvariant(); var upperFilter = filter?.ToUpperInvariant();
var query = await GetQueryableAsync(); var query = await GetQueryableAsync();
if (id.HasValue)
{
return query.Where(x => x.Id == id);
}
if (roleId.HasValue) if (roleId.HasValue)
{ {

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

@ -164,6 +164,7 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
bool includeDetails = false, bool includeDetails = false,
Guid? roleId = null, Guid? roleId = null,
Guid? organizationUnitId = null, Guid? organizationUnitId = null,
Guid? id = null,
string userName = null, string userName = null,
string phoneNumber = null, string phoneNumber = null,
string emailAddress = null, string emailAddress = null,
@ -183,6 +184,7 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
filter, filter,
roleId, roleId,
organizationUnitId, organizationUnitId,
id,
userName, userName,
phoneNumber, phoneNumber,
emailAddress, emailAddress,
@ -243,6 +245,7 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
string filter = null, string filter = null,
Guid? roleId = null, Guid? roleId = null,
Guid? organizationUnitId = null, Guid? organizationUnitId = null,
Guid? id = null,
string userName = null, string userName = null,
string phoneNumber = null, string phoneNumber = null,
string emailAddress = null, string emailAddress = null,
@ -262,6 +265,7 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
filter, filter,
roleId, roleId,
organizationUnitId, organizationUnitId,
id,
userName, userName,
phoneNumber, phoneNumber,
emailAddress, emailAddress,
@ -398,6 +402,7 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
var allOrganizationUnitRoleIds = organizationUnitAndRoleIds.SelectMany(x => x.Roles.Select(r => r.RoleId)).ToList(); var allOrganizationUnitRoleIds = organizationUnitAndRoleIds.SelectMany(x => x.Roles.Select(r => r.RoleId)).ToList();
var allRoleIds = roleIds.Union(allOrganizationUnitRoleIds); var allRoleIds = roleIds.Union(allOrganizationUnitRoleIds);
var roles = await (await GetQueryableAsync<IdentityRole>(cancellationToken)).Where(r => allRoleIds.Contains(r.Id)).Select(r => new{ r.Id, r.Name }).ToListAsync(cancellationToken); var roles = await (await GetQueryableAsync<IdentityRole>(cancellationToken)).Where(r => allRoleIds.Contains(r.Id)).Select(r => new{ r.Id, r.Name }).ToListAsync(cancellationToken);
var userRoles = userAndRoleIds.ToDictionary(x => x.Key, x => roles.Where(r => x.Value.Contains(r.Id)).Select(r => r.Name).ToArray()); var userRoles = userAndRoleIds.ToDictionary(x => x.Key, x => roles.Where(r => x.Value.Contains(r.Id)).Select(r => r.Name).ToArray());
@ -412,9 +417,9 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
{ {
user.RoleNames = user.RoleNames.Union(roleNames).ToArray(); user.RoleNames = user.RoleNames.Union(roleNames).ToArray();
} }
else if(roleNames.Any()) else if (roleNames.Any())
{ {
result.Add(new IdentityUserIdWithRoleNames { Id = userAndOrganizationUnitId.Key, RoleNames = roleNames}); result.Add(new IdentityUserIdWithRoleNames { Id = userAndOrganizationUnitId.Key, RoleNames = roleNames });
} }
} }
@ -425,6 +430,7 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
string filter = null, string filter = null,
Guid? roleId = null, Guid? roleId = null,
Guid? organizationUnitId = null, Guid? organizationUnitId = null,
Guid? id = null,
string userName = null, string userName = null,
string phoneNumber = null, string phoneNumber = null,
string emailAddress = null, string emailAddress = null,
@ -443,6 +449,11 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
var upperFilter = filter?.ToUpperInvariant(); var upperFilter = filter?.ToUpperInvariant();
var query = await GetQueryableAsync(cancellationToken); var query = await GetQueryableAsync(cancellationToken);
if (id.HasValue)
{
return query.Where(x => x.Id == id);
}
if (roleId.HasValue) if (roleId.HasValue)
{ {
var organizationUnitIds = (await GetQueryableAsync<OrganizationUnit>(cancellationToken)) var organizationUnitIds = (await GetQueryableAsync<OrganizationUnit>(cancellationToken))

Loading…
Cancel
Save