mirror of
https://github.com/bitwarden/server.git
synced 2025-07-05 18:12:48 -05:00
[AC-1900] Update Vault DB to support provider billing (#3875)
* Add Gateway columns to Provider table * Add ProviderId column to Transaction table * Create ProviderPlan table * Matt's feedback * Rui's feedback * Fixed Gateway parameter on Provider
This commit is contained in:
@ -0,0 +1,28 @@
|
||||
using System.Data;
|
||||
using Bit.Core.Billing.Entities;
|
||||
using Bit.Core.Billing.Repositories;
|
||||
using Bit.Core.Settings;
|
||||
using Bit.Infrastructure.Dapper.Repositories;
|
||||
using Dapper;
|
||||
using Microsoft.Data.SqlClient;
|
||||
|
||||
namespace Bit.Infrastructure.Dapper.Billing.Repositories;
|
||||
|
||||
public class ProviderPlanRepository(
|
||||
GlobalSettings globalSettings)
|
||||
: Repository<ProviderPlan, Guid>(
|
||||
globalSettings.SqlServer.ConnectionString,
|
||||
globalSettings.SqlServer.ReadOnlyConnectionString), IProviderPlanRepository
|
||||
{
|
||||
public async Task<ProviderPlan> GetByProviderId(Guid providerId)
|
||||
{
|
||||
var sqlConnection = new SqlConnection(ConnectionString);
|
||||
|
||||
var results = await sqlConnection.QueryAsync<ProviderPlan>(
|
||||
"[dbo].[ProviderPlan_ReadByProviderId]",
|
||||
new { ProviderId = providerId },
|
||||
commandType: CommandType.StoredProcedure);
|
||||
|
||||
return results.FirstOrDefault();
|
||||
}
|
||||
}
|
@ -1,11 +1,13 @@
|
||||
using Bit.Core.AdminConsole.Repositories;
|
||||
using Bit.Core.Auth.Repositories;
|
||||
using Bit.Core.Billing.Repositories;
|
||||
using Bit.Core.Repositories;
|
||||
using Bit.Core.SecretsManager.Repositories;
|
||||
using Bit.Core.Tools.Repositories;
|
||||
using Bit.Core.Vault.Repositories;
|
||||
using Bit.Infrastructure.Dapper.AdminConsole.Repositories;
|
||||
using Bit.Infrastructure.Dapper.Auth.Repositories;
|
||||
using Bit.Infrastructure.Dapper.Billing.Repositories;
|
||||
using Bit.Infrastructure.Dapper.Repositories;
|
||||
using Bit.Infrastructure.Dapper.SecretsManager.Repositories;
|
||||
using Bit.Infrastructure.Dapper.Tools.Repositories;
|
||||
@ -48,6 +50,7 @@ public static class DapperServiceCollectionExtensions
|
||||
services.AddSingleton<IUserRepository, UserRepository>();
|
||||
services.AddSingleton<IOrganizationDomainRepository, OrganizationDomainRepository>();
|
||||
services.AddSingleton<IWebAuthnCredentialRepository, WebAuthnCredentialRepository>();
|
||||
services.AddSingleton<IProviderPlanRepository, ProviderPlanRepository>();
|
||||
|
||||
if (selfHosted)
|
||||
{
|
||||
|
@ -44,6 +44,16 @@ public class TransactionRepository : Repository<Transaction, Guid>, ITransaction
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ICollection<Transaction>> GetManyByProviderIdAsync(Guid providerId)
|
||||
{
|
||||
await using var sqlConnection = new SqlConnection(ConnectionString);
|
||||
var results = await sqlConnection.QueryAsync<Transaction>(
|
||||
$"[{Schema}].[Transaction_ReadByProviderId]",
|
||||
new { ProviderId = providerId },
|
||||
commandType: CommandType.StoredProcedure);
|
||||
return results.ToList();
|
||||
}
|
||||
|
||||
public async Task<Transaction> GetByGatewayIdAsync(GatewayType gatewayType, string gatewayId)
|
||||
{
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
|
Reference in New Issue
Block a user