feat: 점검 안내 API 구현 (#92) #93
28
SPMS.API/Controllers/MaintenanceController.cs
Normal file
28
SPMS.API/Controllers/MaintenanceController.cs
Normal file
|
|
@ -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<IActionResult> GetMaintenanceAsync()
|
||||||
|
{
|
||||||
|
var result = await _appConfigService.GetMaintenanceAsync();
|
||||||
|
return Ok(ApiResponse<MaintenanceResponseDto>.Success(result));
|
||||||
|
}
|
||||||
|
}
|
||||||
15
SPMS.Application/DTOs/AppConfig/MaintenanceResponseDto.cs
Normal file
15
SPMS.Application/DTOs/AppConfig/MaintenanceResponseDto.cs
Normal file
|
|
@ -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; }
|
||||||
|
}
|
||||||
|
|
@ -8,4 +8,5 @@ public interface IAppConfigService
|
||||||
Task<AppConfigResponseDto> GetPrivacyAsync();
|
Task<AppConfigResponseDto> GetPrivacyAsync();
|
||||||
Task<AppVersionResponseDto> GetAppVersionAsync(AppVersionRequestDto request);
|
Task<AppVersionResponseDto> GetAppVersionAsync(AppVersionRequestDto request);
|
||||||
Task<AppSettingsResponseDto> GetAppSettingsAsync();
|
Task<AppSettingsResponseDto> GetAppSettingsAsync();
|
||||||
|
Task<MaintenanceResponseDto> GetMaintenanceAsync();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,4 +57,18 @@ public class AppConfigService : IAppConfigService
|
||||||
CsPhone = configDict.GetValueOrDefault("cs_phone")
|
CsPhone = configDict.GetValueOrDefault("cs_phone")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<MaintenanceResponseDto> 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
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user