44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using TaxBaik.Application.Services;
|
|
|
|
namespace TaxBaik.Web.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
[Authorize]
|
|
public class SiteSettingsController : ControllerBase
|
|
{
|
|
private readonly SiteSettingService _siteSettingService;
|
|
|
|
public SiteSettingsController(SiteSettingService siteSettingService)
|
|
{
|
|
_siteSettingService = siteSettingService;
|
|
}
|
|
|
|
[HttpGet]
|
|
public async Task<IActionResult> Get()
|
|
{
|
|
var settings = await _siteSettingService.GetAllAsync();
|
|
return Ok(settings);
|
|
}
|
|
|
|
[HttpPut]
|
|
public async Task<IActionResult> Save([FromBody] SaveSiteSettingsRequest request)
|
|
{
|
|
if (request is null)
|
|
return BadRequest(new { message = "요청 본문이 비어 있습니다." });
|
|
|
|
await _siteSettingService.SaveAsync(request.Phone, request.Email, request.KakaoUrl, request.InstagramUrl);
|
|
return Ok(new { message = "사이트 설정이 저장되었습니다." });
|
|
}
|
|
}
|
|
|
|
public class SaveSiteSettingsRequest
|
|
{
|
|
public string Phone { get; set; } = string.Empty;
|
|
public string Email { get; set; } = string.Empty;
|
|
public string KakaoUrl { get; set; } = string.Empty;
|
|
public string InstagramUrl { get; set; } = string.Empty;
|
|
}
|