refactor: code restructuring
This commit is contained in:
34
Endpoint/Configuration/Model/GeneralConfig.cs
Normal file
34
Endpoint/Configuration/Model/GeneralConfig.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using Mirea.Api.Endpoint.Common.Interfaces;
|
||||
using Mirea.Api.Endpoint.Common.Services;
|
||||
using Mirea.Api.Endpoint.Configuration.ConfigurationChecks.Settings;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Mirea.Api.Endpoint.Configuration.Model;
|
||||
|
||||
public class GeneralConfig : ISaveSettings
|
||||
{
|
||||
[JsonIgnore] private const string FileName = "Settings.json";
|
||||
|
||||
[JsonIgnore]
|
||||
public static string FilePath => PathBuilder.Combine(FileName);
|
||||
|
||||
public DbSettings? DbSettings { get; set; }
|
||||
public CacheSettings? CacheSettings { get; set; }
|
||||
public ScheduleSettings? ScheduleSettings { get; set; }
|
||||
public EmailSettings? EmailSettings { get; set; }
|
||||
public LogSettings? LogSettings { get; set; }
|
||||
public string? SecretForwardToken { get; set; }
|
||||
|
||||
public void SaveSetting()
|
||||
{
|
||||
File.WriteAllText(
|
||||
FilePath,
|
||||
JsonSerializer.Serialize(this, new JsonSerializerOptions
|
||||
{
|
||||
WriteIndented = true
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user