Add Application configuration #11

Merged
Wesser merged 128 commits from feat/add-setup into release/v1.0.0 2024-06-01 07:35:30 +03:00
2 changed files with 53 additions and 0 deletions
Showing only changes of commit f5deeec6c9 - Show all commits

View File

@ -0,0 +1,25 @@
using System.ComponentModel.DataAnnotations;
namespace Mirea.Api.Dto.Requests.Configuration;
/// <summary>
/// Represents a request to configure logging settings.
/// </summary>
public class LoggingRequest
{
/// <summary>
/// Gets or sets a value indicating whether logging to file is enabled.
/// </summary>
[Required]
public bool EnableLogToFile { get; set; }
/// <summary>
/// Gets or sets the log file name.
/// </summary>
public string? LogFileName { get; set; }
/// <summary>
/// Gets or sets the log file path.
/// </summary>
public string? LogFilePath { get; set; }
}

View File

@ -186,6 +186,34 @@ public class SetupController(ISetupToken setupToken, IMaintenanceModeNotConfigur
return Ok(true); return Ok(true);
} }
[HttpPost("SetLogging")]
[TokenAuthentication]
[BadRequestResponse]
public ActionResult<bool> SetLogging([FromBody] LoggingRequest? request)
{
var settings = (request == null) switch
{
true => new LogSettings
{
EnableLogToFile = true,
LogFileName = "logging-",
LogFilePath = "logs"
},
false => new LogSettings
{
EnableLogToFile = request.EnableLogToFile,
LogFileName = request.LogFileName,
LogFilePath = request.LogFilePath
}
};
var general = GeneralConfig;
general.LogSettings = settings;
GeneralConfig = general;
return true;
}
} }