2024-06-01 10:59:23 +03:00
|
|
|
|
using Mirea.Api.DataAccess.Persistence.Common;
|
2024-10-07 02:13:35 +03:00
|
|
|
|
using Mirea.Api.Endpoint.Configuration.ConfigurationChecks.Attributes;
|
|
|
|
|
using Mirea.Api.Endpoint.Configuration.ConfigurationChecks.Interfaces;
|
2024-06-01 10:59:23 +03:00
|
|
|
|
using System;
|
2024-06-01 11:11:21 +03:00
|
|
|
|
using System.Text.Json.Serialization;
|
2024-05-28 06:38:24 +03:00
|
|
|
|
|
2024-10-07 02:13:35 +03:00
|
|
|
|
namespace Mirea.Api.Endpoint.Configuration.ConfigurationChecks.Settings;
|
2024-05-28 06:38:24 +03:00
|
|
|
|
|
|
|
|
|
[RequiredSettings]
|
|
|
|
|
public class DbSettings : IIsConfigured
|
|
|
|
|
{
|
|
|
|
|
public enum DatabaseEnum
|
|
|
|
|
{
|
|
|
|
|
Mysql,
|
|
|
|
|
Sqlite,
|
|
|
|
|
PostgresSql
|
|
|
|
|
}
|
|
|
|
|
public DatabaseEnum TypeDatabase { get; set; }
|
|
|
|
|
public required string ConnectionStringSql { get; set; }
|
|
|
|
|
|
2024-06-01 11:11:21 +03:00
|
|
|
|
[JsonIgnore]
|
2024-05-30 20:25:21 +03:00
|
|
|
|
public DatabaseProvider DatabaseProvider =>
|
|
|
|
|
TypeDatabase switch
|
|
|
|
|
{
|
|
|
|
|
DatabaseEnum.PostgresSql => DatabaseProvider.Postgresql,
|
|
|
|
|
DatabaseEnum.Mysql => DatabaseProvider.Mysql,
|
|
|
|
|
DatabaseEnum.Sqlite => DatabaseProvider.Sqlite,
|
|
|
|
|
_ => throw new ArgumentOutOfRangeException()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public bool IsConfigured() =>
|
|
|
|
|
!string.IsNullOrEmpty(ConnectionStringSql);
|
2024-05-28 06:38:24 +03:00
|
|
|
|
}
|