mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 00:52:49 -05:00
[AC-1750] AC Team code ownership moves - Groups (#3358)
This commit is contained in:
@ -1,19 +1,21 @@
|
||||
using AutoMapper;
|
||||
using Bit.Core.AdminConsole.Repositories;
|
||||
using Bit.Core.Models.Data;
|
||||
using Bit.Core.Repositories;
|
||||
using Bit.Infrastructure.EntityFramework.Models;
|
||||
using Bit.Infrastructure.EntityFramework.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using AdminConsoleEntities = Bit.Core.AdminConsole.Entities;
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Repositories;
|
||||
namespace Bit.Infrastructure.EntityFramework.AdminConsole.Repositories;
|
||||
|
||||
public class GroupRepository : Repository<Core.Entities.Group, Group, Guid>, IGroupRepository
|
||||
public class GroupRepository : Repository<AdminConsoleEntities.Group, Group, Guid>, IGroupRepository
|
||||
{
|
||||
public GroupRepository(IServiceScopeFactory serviceScopeFactory, IMapper mapper)
|
||||
: base(serviceScopeFactory, mapper, (DatabaseContext context) => context.Groups)
|
||||
{ }
|
||||
|
||||
public async Task CreateAsync(Core.Entities.Group obj, IEnumerable<CollectionAccessSelection> collections)
|
||||
public async Task CreateAsync(AdminConsoleEntities.Group obj, IEnumerable<CollectionAccessSelection> collections)
|
||||
{
|
||||
var grp = await base.CreateAsync(obj);
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
@ -51,7 +53,7 @@ public class GroupRepository : Repository<Core.Entities.Group, Group, Guid>, IGr
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<Tuple<Core.Entities.Group, ICollection<CollectionAccessSelection>>> GetByIdWithCollectionsAsync(Guid id)
|
||||
public async Task<Tuple<AdminConsoleEntities.Group, ICollection<CollectionAccessSelection>>> GetByIdWithCollectionsAsync(Guid id)
|
||||
{
|
||||
var grp = await base.GetByIdAsync(id);
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
@ -67,12 +69,12 @@ public class GroupRepository : Repository<Core.Entities.Group, Group, Guid>, IGr
|
||||
ReadOnly = c.ReadOnly,
|
||||
HidePasswords = c.HidePasswords,
|
||||
}).ToList();
|
||||
return new Tuple<Core.Entities.Group, ICollection<CollectionAccessSelection>>(
|
||||
return new Tuple<AdminConsoleEntities.Group, ICollection<CollectionAccessSelection>>(
|
||||
grp, collections);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ICollection<Core.Entities.Group>> GetManyByOrganizationIdAsync(Guid organizationId)
|
||||
public async Task<ICollection<AdminConsoleEntities.Group>> GetManyByOrganizationIdAsync(Guid organizationId)
|
||||
{
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
@ -81,11 +83,11 @@ public class GroupRepository : Repository<Core.Entities.Group, Group, Guid>, IGr
|
||||
from g in dbContext.Groups
|
||||
where g.OrganizationId == organizationId
|
||||
select g).ToListAsync();
|
||||
return Mapper.Map<List<Core.Entities.Group>>(data);
|
||||
return Mapper.Map<List<AdminConsoleEntities.Group>>(data);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ICollection<Tuple<Core.Entities.Group, ICollection<CollectionAccessSelection>>>>
|
||||
public async Task<ICollection<Tuple<AdminConsoleEntities.Group, ICollection<CollectionAccessSelection>>>>
|
||||
GetManyWithCollectionsByOrganizationIdAsync(Guid organizationId)
|
||||
{
|
||||
var groups = await GetManyByOrganizationIdAsync(organizationId);
|
||||
@ -100,7 +102,7 @@ public class GroupRepository : Repository<Core.Entities.Group, Group, Guid>, IGr
|
||||
var collections = query.GroupBy(c => c.GroupId).ToList();
|
||||
|
||||
return groups.Select(group =>
|
||||
new Tuple<Core.Entities.Group, ICollection<CollectionAccessSelection>>(
|
||||
new Tuple<AdminConsoleEntities.Group, ICollection<CollectionAccessSelection>>(
|
||||
group,
|
||||
collections
|
||||
.FirstOrDefault(c => c.Key == group.Id)?
|
||||
@ -115,7 +117,7 @@ public class GroupRepository : Repository<Core.Entities.Group, Group, Guid>, IGr
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ICollection<Core.Entities.Group>> GetManyByManyIds(IEnumerable<Guid> groupIds)
|
||||
public async Task<ICollection<AdminConsoleEntities.Group>> GetManyByManyIds(IEnumerable<Guid> groupIds)
|
||||
{
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
@ -124,11 +126,11 @@ public class GroupRepository : Repository<Core.Entities.Group, Group, Guid>, IGr
|
||||
where groupIds.Contains(g.Id)
|
||||
select g;
|
||||
var groups = await query.ToListAsync();
|
||||
return Mapper.Map<List<Core.Entities.Group>>(groups);
|
||||
return Mapper.Map<List<AdminConsoleEntities.Group>>(groups);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ICollection<Core.Entities.GroupUser>> GetManyGroupUsersByOrganizationIdAsync(Guid organizationId)
|
||||
public async Task<ICollection<AdminConsoleEntities.GroupUser>> GetManyGroupUsersByOrganizationIdAsync(Guid organizationId)
|
||||
{
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
@ -140,7 +142,7 @@ public class GroupRepository : Repository<Core.Entities.Group, Group, Guid>, IGr
|
||||
where g.OrganizationId == organizationId
|
||||
select gu;
|
||||
var groupUsers = await query.ToListAsync();
|
||||
return Mapper.Map<List<Core.Entities.GroupUser>>(groupUsers);
|
||||
return Mapper.Map<List<AdminConsoleEntities.GroupUser>>(groupUsers);
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,7 +174,7 @@ public class GroupRepository : Repository<Core.Entities.Group, Group, Guid>, IGr
|
||||
}
|
||||
}
|
||||
|
||||
public async Task ReplaceAsync(Core.Entities.Group group, IEnumerable<CollectionAccessSelection> requestedCollections)
|
||||
public async Task ReplaceAsync(AdminConsoleEntities.Group group, IEnumerable<CollectionAccessSelection> requestedCollections)
|
||||
{
|
||||
await base.ReplaceAsync(group);
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
@ -1,9 +1,11 @@
|
||||
using Bit.Core.Auth.Repositories;
|
||||
using Bit.Core.AdminConsole.Repositories;
|
||||
using Bit.Core.Auth.Repositories;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Repositories;
|
||||
using Bit.Core.SecretsManager.Repositories;
|
||||
using Bit.Core.Tools.Repositories;
|
||||
using Bit.Core.Vault.Repositories;
|
||||
using Bit.Infrastructure.EntityFramework.AdminConsole.Repositories;
|
||||
using Bit.Infrastructure.EntityFramework.Auth.Repositories;
|
||||
using Bit.Infrastructure.EntityFramework.Repositories;
|
||||
using Bit.Infrastructure.EntityFramework.SecretsManager.Repositories;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Models;
|
||||
|
||||
public class Group : Core.Entities.Group
|
||||
public class Group : Core.AdminConsole.Entities.Group
|
||||
{
|
||||
public virtual Organization Organization { get; set; }
|
||||
public virtual ICollection<GroupUser> GroupUsers { get; set; }
|
||||
@ -12,6 +12,6 @@ public class GroupMapperProfile : Profile
|
||||
{
|
||||
public GroupMapperProfile()
|
||||
{
|
||||
CreateMap<Core.Entities.Group, Group>().ReverseMap();
|
||||
CreateMap<Core.AdminConsole.Entities.Group, Group>().ReverseMap();
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Models;
|
||||
|
||||
public class GroupUser : Core.Entities.GroupUser
|
||||
public class GroupUser : Core.AdminConsole.Entities.GroupUser
|
||||
{
|
||||
public virtual Group Group { get; set; }
|
||||
public virtual OrganizationUser OrganizationUser { get; set; }
|
||||
@ -12,7 +12,7 @@ public class GroupUserMapperProfile : Profile
|
||||
{
|
||||
public GroupUserMapperProfile()
|
||||
{
|
||||
CreateMap<Core.Entities.GroupUser, GroupUser>().ReverseMap();
|
||||
CreateMap<Core.AdminConsole.Entities.GroupUser, GroupUser>().ReverseMap();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user