refactor: change namespace
This commit is contained in:
parent
17e20fee2e
commit
75c1aebea6
@ -4,9 +4,9 @@ using System.IO;
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Mirea.Api.Endpoint.Configuration.General;
|
namespace Mirea.Api.Endpoint.Common.Settings;
|
||||||
|
|
||||||
public class GeneralConfig
|
public class GeneralConfig : ISaveSettings
|
||||||
{
|
{
|
||||||
[JsonIgnore] private const string FileName = "Settings.json";
|
[JsonIgnore] private const string FileName = "Settings.json";
|
||||||
|
|
5
Endpoint/Common/Settings/ISaveSettings.cs
Normal file
5
Endpoint/Common/Settings/ISaveSettings.cs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
namespace Mirea.Api.Endpoint.Common.Settings;
|
||||||
|
public interface ISaveSettings
|
||||||
|
{
|
||||||
|
void SaveSetting();
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Mirea.Api.Endpoint.Configuration.General;
|
using Mirea.Api.Endpoint.Common.Settings;
|
||||||
using Mirea.Api.Endpoint.Configuration.General.Settings;
|
using Mirea.Api.Endpoint.Configuration.General.Settings;
|
||||||
|
|
||||||
namespace Mirea.Api.Endpoint.Configuration.AppConfig;
|
namespace Mirea.Api.Endpoint.Configuration.AppConfig;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Mirea.Api.Endpoint.Common.Services;
|
using Mirea.Api.Endpoint.Common.Services;
|
||||||
using Mirea.Api.Endpoint.Configuration.General;
|
using Mirea.Api.Endpoint.Common.Settings;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
using Serilog.Filters;
|
using Serilog.Filters;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Mirea.Api.Endpoint.Common.Services.Security;
|
using Mirea.Api.Endpoint.Common.Services.Security;
|
||||||
using Mirea.Api.Endpoint.Configuration.General;
|
using Mirea.Api.Endpoint.Common.Settings;
|
||||||
using Mirea.Api.Endpoint.Configuration.General.Settings;
|
using Mirea.Api.Endpoint.Configuration.General.Settings;
|
||||||
using Mirea.Api.Security;
|
using Mirea.Api.Security;
|
||||||
using Mirea.Api.Security.Common.Interfaces;
|
using Mirea.Api.Security.Common.Interfaces;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
using Mirea.Api.Endpoint.Common.Settings;
|
||||||
using Mirea.Api.Endpoint.Configuration.General.Attributes;
|
using Mirea.Api.Endpoint.Configuration.General.Attributes;
|
||||||
using Mirea.Api.Endpoint.Configuration.General.Interfaces;
|
using Mirea.Api.Endpoint.Configuration.General.Interfaces;
|
||||||
using System;
|
using System;
|
||||||
|
@ -8,9 +8,8 @@ using Mirea.Api.Dto.Requests.Configuration;
|
|||||||
using Mirea.Api.Endpoint.Common.Attributes;
|
using Mirea.Api.Endpoint.Common.Attributes;
|
||||||
using Mirea.Api.Endpoint.Common.Exceptions;
|
using Mirea.Api.Endpoint.Common.Exceptions;
|
||||||
using Mirea.Api.Endpoint.Common.Interfaces;
|
using Mirea.Api.Endpoint.Common.Interfaces;
|
||||||
using Mirea.Api.Endpoint.Common.Model;
|
|
||||||
using Mirea.Api.Endpoint.Common.Services;
|
using Mirea.Api.Endpoint.Common.Services;
|
||||||
using Mirea.Api.Endpoint.Configuration.General;
|
using Mirea.Api.Endpoint.Common.Settings;
|
||||||
using Mirea.Api.Endpoint.Configuration.General.Settings;
|
using Mirea.Api.Endpoint.Configuration.General.Settings;
|
||||||
using Mirea.Api.Endpoint.Configuration.General.Validators;
|
using Mirea.Api.Endpoint.Configuration.General.Validators;
|
||||||
using Mirea.Api.Security.Services;
|
using Mirea.Api.Security.Services;
|
||||||
@ -24,7 +23,6 @@ using System.IO;
|
|||||||
using System.Net.Mail;
|
using System.Net.Mail;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text.Json;
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace Mirea.Api.Endpoint.Controllers.Configuration;
|
namespace Mirea.Api.Endpoint.Controllers.Configuration;
|
||||||
@ -333,8 +331,7 @@ public partial class SetupController(
|
|||||||
if (!cache.TryGetValue(CacheAdminKey, out Admin? admin) || admin == null)
|
if (!cache.TryGetValue(CacheAdminKey, out Admin? admin) || admin == null)
|
||||||
throw new ControllerArgumentException("The administrator's data was not set.");
|
throw new ControllerArgumentException("The administrator's data was not set.");
|
||||||
|
|
||||||
System.IO.File.WriteAllText(PathBuilder.Combine(Admin.PathToSave), JsonSerializer.Serialize(admin));
|
admin.SaveSetting();
|
||||||
|
|
||||||
GeneralConfig.SaveSetting();
|
GeneralConfig.SaveSetting();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -6,7 +6,7 @@ using Microsoft.Extensions.Options;
|
|||||||
using Mirea.Api.Dto.Common;
|
using Mirea.Api.Dto.Common;
|
||||||
using Mirea.Api.Dto.Requests;
|
using Mirea.Api.Dto.Requests;
|
||||||
using Mirea.Api.Dto.Responses;
|
using Mirea.Api.Dto.Responses;
|
||||||
using Mirea.Api.Endpoint.Common.Model;
|
using Mirea.Api.Endpoint.Common.Settings;
|
||||||
using Mirea.Api.Security.Common.Dto.Requests;
|
using Mirea.Api.Security.Common.Dto.Requests;
|
||||||
using Mirea.Api.Security.Services;
|
using Mirea.Api.Security.Services;
|
||||||
using System;
|
using System;
|
||||||
|
@ -8,7 +8,7 @@ using Mirea.Api.Dto.Requests;
|
|||||||
using Mirea.Api.Dto.Responses;
|
using Mirea.Api.Dto.Responses;
|
||||||
using Mirea.Api.Endpoint.Common.Attributes;
|
using Mirea.Api.Endpoint.Common.Attributes;
|
||||||
using Mirea.Api.Endpoint.Common.Services;
|
using Mirea.Api.Endpoint.Common.Services;
|
||||||
using Mirea.Api.Endpoint.Configuration.General;
|
using Mirea.Api.Endpoint.Common.Settings;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -7,8 +7,8 @@ using Mirea.Api.DataAccess.Application;
|
|||||||
using Mirea.Api.DataAccess.Persistence;
|
using Mirea.Api.DataAccess.Persistence;
|
||||||
using Mirea.Api.DataAccess.Persistence.Common;
|
using Mirea.Api.DataAccess.Persistence.Common;
|
||||||
using Mirea.Api.Endpoint.Common.Interfaces;
|
using Mirea.Api.Endpoint.Common.Interfaces;
|
||||||
using Mirea.Api.Endpoint.Common.Model;
|
|
||||||
using Mirea.Api.Endpoint.Common.Services;
|
using Mirea.Api.Endpoint.Common.Services;
|
||||||
|
using Mirea.Api.Endpoint.Common.Settings;
|
||||||
using Mirea.Api.Endpoint.Configuration.AppConfig;
|
using Mirea.Api.Endpoint.Configuration.AppConfig;
|
||||||
using Mirea.Api.Endpoint.Configuration.General;
|
using Mirea.Api.Endpoint.Configuration.General;
|
||||||
using Mirea.Api.Endpoint.Configuration.General.Validators;
|
using Mirea.Api.Endpoint.Configuration.General.Validators;
|
||||||
@ -40,7 +40,7 @@ public class Program
|
|||||||
builder.Configuration.AddConfiguration(EnvironmentConfiguration.GetEnvironment());
|
builder.Configuration.AddConfiguration(EnvironmentConfiguration.GetEnvironment());
|
||||||
builder.Configuration.AddJsonFile(GeneralConfig.FilePath, optional: true, reloadOnChange: true);
|
builder.Configuration.AddJsonFile(GeneralConfig.FilePath, optional: true, reloadOnChange: true);
|
||||||
builder.Services.Configure<GeneralConfig>(builder.Configuration);
|
builder.Services.Configure<GeneralConfig>(builder.Configuration);
|
||||||
builder.Configuration.AddJsonFile(PathBuilder.Combine(Admin.PathToSave), optional: true, reloadOnChange: true);
|
builder.Configuration.AddJsonFile(Admin.FilePath, optional: true, reloadOnChange: true);
|
||||||
builder.Services.Configure<Admin>(builder.Configuration);
|
builder.Services.Configure<Admin>(builder.Configuration);
|
||||||
|
|
||||||
builder.Host.AddCustomSerilog();
|
builder.Host.AddCustomSerilog();
|
||||||
|
Loading…
Reference in New Issue
Block a user