diff --git a/SPMS.API/Controllers/MaintenanceController.cs b/SPMS.API/Controllers/MaintenanceController.cs new file mode 100644 index 0000000..4f62ee5 --- /dev/null +++ b/SPMS.API/Controllers/MaintenanceController.cs @@ -0,0 +1,28 @@ +using Microsoft.AspNetCore.Mvc; +using Swashbuckle.AspNetCore.Annotations; +using SPMS.Application.DTOs.AppConfig; +using SPMS.Application.Interfaces; +using SPMS.Domain.Common; + +namespace SPMS.API.Controllers; + +[ApiController] +[Route("v1/in/public")] +[ApiExplorerSettings(GroupName = "public")] +public class MaintenanceController : ControllerBase +{ + private readonly IAppConfigService _appConfigService; + + public MaintenanceController(IAppConfigService appConfigService) + { + _appConfigService = appConfigService; + } + + [HttpPost("maintenance")] + [SwaggerOperation(Summary = "점검 안내", Description = "현재 서비스 점검 상태를 조회합니다.")] + public async Task GetMaintenanceAsync() + { + var result = await _appConfigService.GetMaintenanceAsync(); + return Ok(ApiResponse.Success(result)); + } +} diff --git a/SPMS.Application/DTOs/AppConfig/MaintenanceResponseDto.cs b/SPMS.Application/DTOs/AppConfig/MaintenanceResponseDto.cs new file mode 100644 index 0000000..cb0203e --- /dev/null +++ b/SPMS.Application/DTOs/AppConfig/MaintenanceResponseDto.cs @@ -0,0 +1,15 @@ +using System.Text.Json.Serialization; + +namespace SPMS.Application.DTOs.AppConfig; + +public class MaintenanceResponseDto +{ + [JsonPropertyName("is_maintenance")] + public bool IsMaintenance { get; set; } + + [JsonPropertyName("maintenance_msg")] + public string? MaintenanceMsg { get; set; } + + [JsonPropertyName("estimated_end_time")] + public string? EstimatedEndTime { get; set; } +} diff --git a/SPMS.Application/Interfaces/IAppConfigService.cs b/SPMS.Application/Interfaces/IAppConfigService.cs index 4234dae..9860192 100644 --- a/SPMS.Application/Interfaces/IAppConfigService.cs +++ b/SPMS.Application/Interfaces/IAppConfigService.cs @@ -8,4 +8,5 @@ public interface IAppConfigService Task GetPrivacyAsync(); Task GetAppVersionAsync(AppVersionRequestDto request); Task GetAppSettingsAsync(); + Task GetMaintenanceAsync(); } diff --git a/SPMS.Application/Services/AppConfigService.cs b/SPMS.Application/Services/AppConfigService.cs index 8e31d71..cd22dbf 100644 --- a/SPMS.Application/Services/AppConfigService.cs +++ b/SPMS.Application/Services/AppConfigService.cs @@ -57,4 +57,18 @@ public class AppConfigService : IAppConfigService CsPhone = configDict.GetValueOrDefault("cs_phone") }; } + + public async Task GetMaintenanceAsync() + { + var maintenanceMode = await _appConfigRepository.GetByKeyAsync("maintenance_mode"); + var maintenanceMessage = await _appConfigRepository.GetByKeyAsync("maintenance_message"); + var maintenanceEndTime = await _appConfigRepository.GetByKeyAsync("maintenance_end_time"); + + return new MaintenanceResponseDto + { + IsMaintenance = string.Equals(maintenanceMode?.ConfigValue, "true", StringComparison.OrdinalIgnoreCase), + MaintenanceMsg = maintenanceMessage?.ConfigValue, + EstimatedEndTime = maintenanceEndTime?.ConfigValue + }; + } }