Browse Source

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

Vs internal issue #5807
issue/assign-available-port-for-suite
oykuermann 1 year 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,
Guid? roleId = null,
Guid? organizationUnitId = null,
Guid? id = null,
string userName = null,
string phoneNumber = null,
string emailAddress = null,
@ -114,6 +115,7 @@ public interface IIdentityUserRepository : IBasicRepository<IdentityUser, Guid>
string filter = null,
Guid? roleId = null,
Guid? organizationUnitId = null,
Guid? id = null,
string userName = null,
string phoneNumber = 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 userRoles = await (from userRole in dbContext.Set<IdentityUserRole>()
join role in dbContext.Roles on userRole.RoleId equals role.Id
where userIds.Contains(userRole.UserId)
group new
{
userRole.UserId,
role.Name
} by userRole.UserId
join role in dbContext.Roles on userRole.RoleId equals role.Id
where userIds.Contains(userRole.UserId)
group new {
userRole.UserId,
role.Name
} by userRole.UserId
into gp
select new IdentityUserIdWithRoleNames
{
Id = gp.Key, RoleNames = gp.Select(x => x.Name).ToArray()
}).ToListAsync(cancellationToken: cancellationToken);
select new IdentityUserIdWithRoleNames
{
Id = gp.Key,
RoleNames = gp.Select(x => x.Name).ToArray()
}).ToListAsync(cancellationToken: cancellationToken);
var orgUnitRoles = await (from userOu in dbContext.Set<IdentityUserOrganizationUnit>()
join roleOu in dbContext.Set<OrganizationUnitRole>() on userOu.OrganizationUnitId equals roleOu.OrganizationUnitId
join role in dbContext.Roles on roleOu.RoleId equals role.Id
where userIds.Contains(userOu.UserId)
group new
{
userOu.UserId,
role.Name
} by userOu.UserId
join roleOu in dbContext.Set<OrganizationUnitRole>() on userOu.OrganizationUnitId equals roleOu.OrganizationUnitId
join role in dbContext.Roles on roleOu.RoleId equals role.Id
where userIds.Contains(userOu.UserId)
group new {
userOu.UserId,
role.Name
} by userOu.UserId
into gp
select new IdentityUserIdWithRoleNames
{
Id = gp.Key, RoleNames = gp.Select(x => x.Name).ToArray()
}).ToListAsync(cancellationToken: cancellationToken);
select new IdentityUserIdWithRoleNames
{
Id = gp.Key,
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(
@ -196,6 +196,7 @@ public class EfCoreIdentityUserRepository : EfCoreRepository<IIdentityDbContext,
bool includeDetails = false,
Guid? roleId = null,
Guid? organizationUnitId = null,
Guid? id = null,
string userName = null,
string phoneNumber = null,
string emailAddress = null,
@ -215,6 +216,7 @@ public class EfCoreIdentityUserRepository : EfCoreRepository<IIdentityDbContext,
filter,
roleId,
organizationUnitId,
id,
userName,
phoneNumber,
emailAddress,
@ -272,6 +274,7 @@ public class EfCoreIdentityUserRepository : EfCoreRepository<IIdentityDbContext,
string filter = null,
Guid? roleId = null,
Guid? organizationUnitId = null,
Guid? id = null,
string userName = null,
string phoneNumber = null,
string emailAddress = null,
@ -291,6 +294,7 @@ public class EfCoreIdentityUserRepository : EfCoreRepository<IIdentityDbContext,
filter,
roleId,
organizationUnitId,
id,
userName,
phoneNumber,
emailAddress,
@ -434,6 +438,7 @@ public class EfCoreIdentityUserRepository : EfCoreRepository<IIdentityDbContext,
string filter = null,
Guid? roleId = null,
Guid? organizationUnitId = null,
Guid? id = null,
string userName = null,
string phoneNumber = null,
string emailAddress = null,
@ -451,6 +456,11 @@ public class EfCoreIdentityUserRepository : EfCoreRepository<IIdentityDbContext,
{
var upperFilter = filter?.ToUpperInvariant();
var query = await GetQueryableAsync();
if (id.HasValue)
{
return query.Where(x => x.Id == id);
}
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,
Guid? roleId = null,
Guid? organizationUnitId = null,
Guid? id = null,
string userName = null,
string phoneNumber = null,
string emailAddress = null,
@ -183,6 +184,7 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
filter,
roleId,
organizationUnitId,
id,
userName,
phoneNumber,
emailAddress,
@ -243,6 +245,7 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
string filter = null,
Guid? roleId = null,
Guid? organizationUnitId = null,
Guid? id = null,
string userName = null,
string phoneNumber = null,
string emailAddress = null,
@ -262,6 +265,7 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
filter,
roleId,
organizationUnitId,
id,
userName,
phoneNumber,
emailAddress,
@ -398,6 +402,7 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
var allOrganizationUnitRoleIds = organizationUnitAndRoleIds.SelectMany(x => x.Roles.Select(r => r.RoleId)).ToList();
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 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();
}
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,
Guid? roleId = null,
Guid? organizationUnitId = null,
Guid? id = null,
string userName = null,
string phoneNumber = null,
string emailAddress = null,
@ -443,6 +449,11 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
var upperFilter = filter?.ToUpperInvariant();
var query = await GetQueryableAsync(cancellationToken);
if (id.HasValue)
{
return query.Where(x => x.Id == id);
}
if (roleId.HasValue)
{
var organizationUnitIds = (await GetQueryableAsync<OrganizationUnit>(cancellationToken))

Loading…
Cancel
Save