1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-05 05:00:19 -05:00

Initial buildout of basic repositories

This commit is contained in:
Brant DeBow 2025-03-26 15:26:02 -04:00
parent 6300a959e4
commit f25b308f57
No known key found for this signature in database
GPG Key ID: 94411BB25947C72B
4 changed files with 88 additions and 0 deletions

View File

@ -0,0 +1,22 @@
using Bit.Core.AdminConsole.Entities;
using Bit.Core.Enums;
namespace Bit.Core.Repositories;
public interface IOrganizationIntegrationConfigurationRepository : IRepository<OrganizationIntegrationConfiguration, Guid>
{
Task<List<OrganizationIntegrationConfiguration>> GetConfigurationsAsync(
Guid organizationId,
IntegrationType integrationType,
EventType eventType);
// Task<List<IntegrationConfiguration<T>>> GetConfigurationsAsync<T>(
// Guid organizationId,
// IntegrationType integrationType,
// EventType eventType);
//
// Task CreateOrganizationIntegrationAsync<T>(
// Guid organizationId,
// IntegrationType integrationType,
// T configuration);
}

View File

@ -0,0 +1,7 @@
using Bit.Core.AdminConsole.Entities;
namespace Bit.Core.Repositories;
public interface IOrganizationIntegrationRepository : IRepository<OrganizationIntegration, Guid>
{
}

View File

@ -0,0 +1,43 @@
using System.Data;
using Bit.Core.AdminConsole.Entities;
using Bit.Core.Enums;
using Bit.Core.Repositories;
using Bit.Core.Settings;
using Bit.Infrastructure.Dapper.Repositories;
using Dapper;
using Microsoft.Data.SqlClient;
namespace Bit.Infrastructure.Dapper.AdminConsole.Repositories;
public class OrganizationIntegrationConfigurationRepository : Repository<OrganizationIntegrationConfiguration, Guid>, IOrganizationIntegrationConfigurationRepository
{
public OrganizationIntegrationConfigurationRepository(GlobalSettings globalSettings)
: this(globalSettings.SqlServer.ConnectionString, globalSettings.SqlServer.ReadOnlyConnectionString)
{ }
public OrganizationIntegrationConfigurationRepository(string connectionString, string readOnlyConnectionString)
: base(connectionString, readOnlyConnectionString)
{ }
public async Task<List<OrganizationIntegrationConfiguration>> GetConfigurationsAsync(
Guid organizationId,
IntegrationType integrationType,
EventType eventType)
{
using (var connection = new SqlConnection(ConnectionString))
{
var results = await connection.QueryAsync<OrganizationIntegrationConfiguration>(
"[dbo].[OrganizationIntegrationConfiguration_ReadManyByEventTypeOrganizationIdIntegrationType]",
new
{
EventType = eventType,
OrganizationId = organizationId,
IntegrationType = integrationType
},
commandType: CommandType.StoredProcedure);
return results.ToList();
}
}
}

View File

@ -0,0 +1,16 @@
using Bit.Core.AdminConsole.Entities;
using Bit.Core.Repositories;
using Bit.Core.Settings;
namespace Bit.Infrastructure.Dapper.Repositories;
public class OrganizationIntegrationRepository : Repository<OrganizationIntegration, Guid>, IOrganizationIntegrationRepository
{
public OrganizationIntegrationRepository(GlobalSettings globalSettings)
: this(globalSettings.SqlServer.ConnectionString, globalSettings.SqlServer.ReadOnlyConnectionString)
{ }
public OrganizationIntegrationRepository(string connectionString, string readOnlyConnectionString)
: base(connectionString, readOnlyConnectionString)
{ }
}