mirror of
https://github.com/bitwarden/server.git
synced 2025-06-25 13:18:48 -05:00
PM-20574 changing table and repo names as requested
This commit is contained in:
parent
3f9ffbb2b8
commit
b62603f586
@ -5,7 +5,7 @@ using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.Dirt.Reports.Entities;
|
||||
|
||||
public class RiskInsightCriticalApplication : ITableObject<Guid>, IRevisable
|
||||
public class OrganizationApplication : ITableObject<Guid>, IRevisable
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid OrganizationId { get; set; }
|
@ -5,7 +5,7 @@ using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.Dirt.Reports.Entities;
|
||||
|
||||
public class RiskInsightReport : ITableObject<Guid>, IRevisable
|
||||
public class OrganizationReport : ITableObject<Guid>, IRevisable
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid OrganizationId { get; set; }
|
@ -0,0 +1,9 @@
|
||||
using Bit.Core.Dirt.Reports.Entities;
|
||||
using Bit.Core.Repositories;
|
||||
|
||||
namespace Bit.Core.Dirt.Reports.Repositories;
|
||||
|
||||
public interface IOrganizationApplicationRepository : IRepository<OrganizationApplication, Guid>
|
||||
{
|
||||
Task<ICollection<OrganizationApplication>> GetByOrganizationIdAsync(Guid organizationId);
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
using Bit.Core.Dirt.Reports.Entities;
|
||||
using Bit.Core.Repositories;
|
||||
|
||||
namespace Bit.Core.Dirt.Reports.Repositories;
|
||||
|
||||
public interface IOrganizationReportRepository : IRepository<OrganizationReport, Guid>
|
||||
{
|
||||
Task<ICollection<OrganizationReport>> GetByOrganizationIdAsync(Guid organizationId);
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
using Bit.Core.Dirt.Reports.Entities;
|
||||
using Bit.Core.Repositories;
|
||||
|
||||
namespace Bit.Core.Dirt.Reports.Repositories;
|
||||
|
||||
public interface IRiskInsightCriticalApplicationRepository : IRepository<RiskInsightCriticalApplication, Guid>
|
||||
{
|
||||
Task<ICollection<RiskInsightCriticalApplication>> GetByOrganizationIdAsync(Guid organizationId);
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
using Bit.Core.Dirt.Reports.Entities;
|
||||
using Bit.Core.Repositories;
|
||||
|
||||
namespace Bit.Core.Dirt.Reports.Repositories;
|
||||
|
||||
public interface IRiskInsightReportRepository : IRepository<RiskInsightReport, Guid>
|
||||
{
|
||||
Task<ICollection<RiskInsightReport>> GetByOrganizationIdAsync(Guid organizationId);
|
||||
}
|
||||
|
@ -69,8 +69,8 @@ public static class DapperServiceCollectionExtensions
|
||||
services.AddSingleton<ISecurityTaskRepository, SecurityTaskRepository>();
|
||||
services.AddSingleton<IUserAsymmetricKeysRepository, UserAsymmetricKeysRepository>();
|
||||
services.AddSingleton<IOrganizationInstallationRepository, OrganizationInstallationRepository>();
|
||||
services.AddSingleton<IRiskInsightReportRepository, RiskInsightReportRepository>();
|
||||
services.AddSingleton<IRiskInsightCriticalApplicationRepository, RiskInsightCriticalApplicationRepository>();
|
||||
services.AddSingleton<IOrganizationReportRepository, OrganizationReportRepository>();
|
||||
services.AddSingleton<IOrganizationApplicationRepository, OrganizationApplicationRepository>();
|
||||
|
||||
if (selfHosted)
|
||||
{
|
||||
|
@ -8,23 +8,23 @@ using Microsoft.Data.SqlClient;
|
||||
|
||||
namespace Bit.Infrastructure.Dapper.Dirt;
|
||||
|
||||
public class RiskInsightCriticalApplicationRepository : Repository<RiskInsightCriticalApplication, Guid>, IRiskInsightCriticalApplicationRepository
|
||||
public class OrganizationApplicationRepository : Repository<OrganizationApplication, Guid>, IOrganizationApplicationRepository
|
||||
{
|
||||
public RiskInsightCriticalApplicationRepository(GlobalSettings globalSettings)
|
||||
public OrganizationApplicationRepository(GlobalSettings globalSettings)
|
||||
: this(globalSettings.SqlServer.ConnectionString, globalSettings.SqlServer.ReadOnlyConnectionString)
|
||||
{
|
||||
}
|
||||
|
||||
public RiskInsightCriticalApplicationRepository(string connectionString, string readOnlyConnectionString)
|
||||
public OrganizationApplicationRepository(string connectionString, string readOnlyConnectionString)
|
||||
: base(connectionString, readOnlyConnectionString)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<ICollection<RiskInsightCriticalApplication>> GetByOrganizationIdAsync(Guid organizationId)
|
||||
public async Task<ICollection<OrganizationApplication>> GetByOrganizationIdAsync(Guid organizationId)
|
||||
{
|
||||
using (var connection = new SqlConnection(ReadOnlyConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<RiskInsightCriticalApplication>(
|
||||
var results = await connection.QueryAsync<OrganizationApplication>(
|
||||
$"[{Schema}].[RiskInsightCriticalApplication_ReadByOrganizationId]",
|
||||
new { OrganizationId = organizationId },
|
||||
commandType: CommandType.StoredProcedure);
|
@ -8,23 +8,23 @@ using Microsoft.Data.SqlClient;
|
||||
|
||||
namespace Bit.Infrastructure.Dapper.Dirt;
|
||||
|
||||
public class RiskInsightReportRepository : Repository<RiskInsightReport, Guid>, IRiskInsightReportRepository
|
||||
public class OrganizationReportRepository : Repository<OrganizationReport, Guid>, IOrganizationReportRepository
|
||||
{
|
||||
public RiskInsightReportRepository(GlobalSettings globalSettings)
|
||||
public OrganizationReportRepository(GlobalSettings globalSettings)
|
||||
: this(globalSettings.SqlServer.ConnectionString, globalSettings.SqlServer.ReadOnlyConnectionString)
|
||||
{
|
||||
}
|
||||
|
||||
public RiskInsightReportRepository(string connectionString, string readOnlyConnectionString)
|
||||
public OrganizationReportRepository(string connectionString, string readOnlyConnectionString)
|
||||
: base(connectionString, readOnlyConnectionString)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<ICollection<RiskInsightReport>> GetByOrganizationIdAsync(Guid organizationId)
|
||||
public async Task<ICollection<OrganizationReport>> GetByOrganizationIdAsync(Guid organizationId)
|
||||
{
|
||||
using (var connection = new SqlConnection(ReadOnlyConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<RiskInsightReport>(
|
||||
var results = await connection.QueryAsync<OrganizationReport>(
|
||||
$"[{Schema}].[RiskInsightReport_ReadByOrganizationId]",
|
||||
new { OrganizationId = organizationId },
|
||||
commandType: CommandType.StoredProcedure);
|
@ -4,9 +4,9 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Dirt.Configurations;
|
||||
|
||||
public class RiskInsightCriticalApplicationEntityTypeConfiguration : IEntityTypeConfiguration<RiskInsightCriticalApplication>
|
||||
public class RiskInsightCriticalApplicationEntityTypeConfiguration : IEntityTypeConfiguration<OrganizationApplication>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<RiskInsightCriticalApplication> builder)
|
||||
public void Configure(EntityTypeBuilder<OrganizationApplication> builder)
|
||||
{
|
||||
builder
|
||||
.Property(s => s.Id)
|
||||
@ -19,6 +19,6 @@ public class RiskInsightCriticalApplicationEntityTypeConfiguration : IEntityType
|
||||
.HasIndex(s => s.OrganizationId)
|
||||
.IsClustered(false);
|
||||
|
||||
builder.ToTable(nameof(RiskInsightCriticalApplication));
|
||||
builder.ToTable(nameof(OrganizationApplication));
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,9 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Dirt.Configurations;
|
||||
|
||||
public class RiskInsightReportEntityTypeConfiguration : IEntityTypeConfiguration<RiskInsightReport>
|
||||
public class RiskInsightReportEntityTypeConfiguration : IEntityTypeConfiguration<OrganizationReport>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<RiskInsightReport> builder)
|
||||
public void Configure(EntityTypeBuilder<OrganizationReport> builder)
|
||||
{
|
||||
builder
|
||||
.Property(s => s.Id)
|
||||
@ -19,6 +19,6 @@ public class RiskInsightReportEntityTypeConfiguration : IEntityTypeConfiguration
|
||||
.HasIndex(s => s.OrganizationId)
|
||||
.IsClustered(false);
|
||||
|
||||
builder.ToTable(nameof(RiskInsightReport));
|
||||
builder.ToTable(nameof(OrganizationReport));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
using AutoMapper;
|
||||
using Bit.Infrastructure.EntityFramework.AdminConsole.Models;
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Dirt.Models;
|
||||
public class OrganizationApplication : Core.Dirt.Reports.Entities.OrganizationApplication
|
||||
{
|
||||
public virtual Organization Organization { get; set; }
|
||||
}
|
||||
|
||||
public class OrganizationApplicationProfile : Profile
|
||||
{
|
||||
public OrganizationApplicationProfile()
|
||||
{
|
||||
CreateMap<Core.Dirt.Reports.Entities.OrganizationApplication, OrganizationApplication>()
|
||||
.ReverseMap();
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using AutoMapper;
|
||||
using Bit.Infrastructure.EntityFramework.AdminConsole.Models;
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Dirt.Models;
|
||||
public class OrganizationReport : Core.Dirt.Reports.Entities.OrganizationReport
|
||||
{
|
||||
public virtual Organization Organization { get; set; }
|
||||
}
|
||||
|
||||
public class OrganizationReportProfile : Profile
|
||||
{
|
||||
public OrganizationReportProfile()
|
||||
{
|
||||
CreateMap<Core.Dirt.Reports.Entities.OrganizationReport, OrganizationReport>()
|
||||
.ReverseMap();
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
using AutoMapper;
|
||||
using Bit.Infrastructure.EntityFramework.AdminConsole.Models;
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Dirt.Models;
|
||||
public class RiskInsightCriticalApplication : Core.Dirt.Reports.Entities.RiskInsightCriticalApplication
|
||||
{
|
||||
public virtual Organization Organization { get; set; }
|
||||
}
|
||||
|
||||
public class RiskInsightCriticalApplicationProfile : Profile
|
||||
{
|
||||
public RiskInsightCriticalApplicationProfile()
|
||||
{
|
||||
CreateMap<Core.Dirt.Reports.Entities.RiskInsightCriticalApplication, RiskInsightCriticalApplication>()
|
||||
.ReverseMap();
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
using AutoMapper;
|
||||
using Bit.Infrastructure.EntityFramework.AdminConsole.Models;
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Dirt.Models;
|
||||
public class RiskInsightReport : Core.Dirt.Reports.Entities.RiskInsightReport
|
||||
{
|
||||
public virtual Organization Organization { get; set; }
|
||||
}
|
||||
|
||||
public class RiskInsightReportProfile : Profile
|
||||
{
|
||||
public RiskInsightReportProfile()
|
||||
{
|
||||
CreateMap<Core.Dirt.Reports.Entities.RiskInsightReport, RiskInsightReport>()
|
||||
.ReverseMap();
|
||||
}
|
||||
}
|
@ -5,26 +5,25 @@ using Bit.Infrastructure.EntityFramework.Repositories;
|
||||
using LinqToDB;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Dirt.Repositories;
|
||||
|
||||
public class RiskInsightReportRepository :
|
||||
Repository<Core.Dirt.Reports.Entities.RiskInsightReport, RiskInsightReport, Guid>,
|
||||
IRiskInsightReportRepository
|
||||
public class OrganizationApplicationRepository :
|
||||
Repository<Core.Dirt.Reports.Entities.OrganizationApplication, OrganizationApplication, Guid>,
|
||||
IOrganizationApplicationRepository
|
||||
{
|
||||
public RiskInsightReportRepository(IServiceScopeFactory serviceScopeFactory,
|
||||
IMapper mapper) : base(serviceScopeFactory, mapper, (DatabaseContext context) => context.RiskInsightReports)
|
||||
public OrganizationApplicationRepository(IServiceScopeFactory serviceScopeFactory,
|
||||
IMapper mapper) : base(serviceScopeFactory, mapper, (DatabaseContext context) => context.OrganizationApplications)
|
||||
{ }
|
||||
|
||||
public async Task<ICollection<Core.Dirt.Reports.Entities.RiskInsightReport>> GetByOrganizationIdAsync(Guid organizationId)
|
||||
public async Task<ICollection<Core.Dirt.Reports.Entities.OrganizationApplication>> GetByOrganizationIdAsync(Guid organizationId)
|
||||
{
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var results = await dbContext.RiskInsightReports
|
||||
var results = await dbContext.OrganizationApplications
|
||||
.Where(p => p.OrganizationId == organizationId)
|
||||
.ToListAsync();
|
||||
return Mapper.Map<ICollection<Core.Dirt.Reports.Entities.RiskInsightReport>>(results);
|
||||
return Mapper.Map<ICollection<Core.Dirt.Reports.Entities.OrganizationApplication>>(results);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
using AutoMapper;
|
||||
using Bit.Core.Dirt.Reports.Entities;
|
||||
using Bit.Core.Dirt.Reports.Repositories;
|
||||
using Bit.Infrastructure.EntityFramework.Repositories;
|
||||
using LinqToDB;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Dirt.Repositories;
|
||||
|
||||
public class OrganizationReportRepository :
|
||||
Repository<OrganizationReport, Models.OrganizationReport, Guid>,
|
||||
IOrganizationReportRepository
|
||||
{
|
||||
public OrganizationReportRepository(IServiceScopeFactory serviceScopeFactory,
|
||||
IMapper mapper) : base(serviceScopeFactory, mapper, (DatabaseContext context) => context.OrganizationReports)
|
||||
{ }
|
||||
|
||||
public async Task<ICollection<OrganizationReport>> GetByOrganizationIdAsync(Guid organizationId)
|
||||
{
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var results = await dbContext.OrganizationReports
|
||||
.Where(p => p.OrganizationId == organizationId)
|
||||
.ToListAsync();
|
||||
return Mapper.Map<ICollection<OrganizationReport>>(results);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
using AutoMapper;
|
||||
using Bit.Core.Dirt.Reports.Repositories;
|
||||
using Bit.Infrastructure.EntityFramework.Dirt.Models;
|
||||
using Bit.Infrastructure.EntityFramework.Repositories;
|
||||
using LinqToDB;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Dirt.Repositories;
|
||||
|
||||
public class RiskInsightCriticalApplicationRepository :
|
||||
Repository<Core.Dirt.Reports.Entities.RiskInsightCriticalApplication, RiskInsightCriticalApplication, Guid>,
|
||||
IRiskInsightCriticalApplicationRepository
|
||||
{
|
||||
public RiskInsightCriticalApplicationRepository(IServiceScopeFactory serviceScopeFactory,
|
||||
IMapper mapper) : base(serviceScopeFactory, mapper, (DatabaseContext context) => context.RiskInsightCriticalApplications)
|
||||
{ }
|
||||
|
||||
public async Task<ICollection<Core.Dirt.Reports.Entities.RiskInsightCriticalApplication>> GetByOrganizationIdAsync(Guid organizationId)
|
||||
{
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var results = await dbContext.RiskInsightCriticalApplications
|
||||
.Where(p => p.OrganizationId == organizationId)
|
||||
.ToListAsync();
|
||||
return Mapper.Map<ICollection<Core.Dirt.Reports.Entities.RiskInsightCriticalApplication>>(results);
|
||||
}
|
||||
}
|
||||
}
|
@ -106,8 +106,8 @@ public static class EntityFrameworkServiceCollectionExtensions
|
||||
services.AddSingleton<ISecurityTaskRepository, SecurityTaskRepository>();
|
||||
services.AddSingleton<IUserAsymmetricKeysRepository, UserAsymmetricKeysRepository>();
|
||||
services.AddSingleton<IOrganizationInstallationRepository, OrganizationInstallationRepository>();
|
||||
services.AddSingleton<IRiskInsightReportRepository, RiskInsightReportRepository>();
|
||||
services.AddSingleton<IRiskInsightCriticalApplicationRepository, RiskInsightCriticalApplicationRepository>();
|
||||
services.AddSingleton<IOrganizationReportRepository, OrganizationReportRepository>();
|
||||
services.AddSingleton<IOrganizationApplicationRepository, OrganizationApplicationRepository>();
|
||||
|
||||
if (selfHosted)
|
||||
{
|
||||
|
@ -15,6 +15,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using DP = Microsoft.AspNetCore.DataProtection;
|
||||
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Repositories;
|
||||
@ -82,8 +83,8 @@ public class DatabaseContext : DbContext
|
||||
public DbSet<PasswordHealthReportApplication> PasswordHealthReportApplications { get; set; }
|
||||
public DbSet<SecurityTask> SecurityTasks { get; set; }
|
||||
public DbSet<OrganizationInstallation> OrganizationInstallations { get; set; }
|
||||
public DbSet<RiskInsightReport> RiskInsightReports { get; set; }
|
||||
public DbSet<RiskInsightCriticalApplication> RiskInsightCriticalApplications { get; set; }
|
||||
public DbSet<OrganizationReport> OrganizationReports { get; set; }
|
||||
public DbSet<OrganizationApplication> OrganizationApplications { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user