feat: 이용약관/개인정보처리방침 API 구현 (#84) #85

Merged
seonkyu.kim merged 1 commits from feature/#84-terms-privacy into develop 2026-02-10 05:09:00 +00:00
8 changed files with 130 additions and 0 deletions
Showing only changes of commit 6475c0c753 - Show all commits

View File

@ -0,0 +1,44 @@
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 TermsController : ControllerBase
{
private readonly IAppConfigService _appConfigService;
public TermsController(IAppConfigService appConfigService)
{
_appConfigService = appConfigService;
}
[HttpPost("terms")]
[SwaggerOperation(Summary = "이용약관", Description = "이용약관 URL을 조회합니다.")]
public async Task<IActionResult> GetTermsAsync()
{
var serviceCode = Request.Headers["X-Service-Code"].FirstOrDefault();
if (string.IsNullOrWhiteSpace(serviceCode))
return BadRequest(ApiResponse.Fail(ErrorCodes.BadRequest, "X-Service-Code 헤더가 필요합니다."));
var result = await _appConfigService.GetTermsAsync(serviceCode);
return Ok(ApiResponse<AppConfigResponseDto>.Success(result));
}
[HttpPost("privacy")]
[SwaggerOperation(Summary = "개인정보처리방침", Description = "개인정보처리방침 URL을 조회합니다.")]
public async Task<IActionResult> GetPrivacyAsync()
{
var serviceCode = Request.Headers["X-Service-Code"].FirstOrDefault();
if (string.IsNullOrWhiteSpace(serviceCode))
return BadRequest(ApiResponse.Fail(ErrorCodes.BadRequest, "X-Service-Code 헤더가 필요합니다."));
var result = await _appConfigService.GetPrivacyAsync(serviceCode);
return Ok(ApiResponse<AppConfigResponseDto>.Success(result));
}
}

View File

@ -0,0 +1,9 @@
using System.Text.Json.Serialization;
namespace SPMS.Application.DTOs.AppConfig;
public class AppConfigResponseDto
{
[JsonPropertyName("url")]
public string? Url { get; set; }
}

View File

@ -15,6 +15,7 @@ public static class DependencyInjection
services.AddScoped<INoticeService, NoticeService>();
services.AddScoped<IBannerService, BannerService>();
services.AddScoped<IFaqService, FaqService>();
services.AddScoped<IAppConfigService, AppConfigService>();
return services;
}

View File

@ -0,0 +1,9 @@
using SPMS.Application.DTOs.AppConfig;
namespace SPMS.Application.Interfaces;
public interface IAppConfigService
{
Task<AppConfigResponseDto> GetTermsAsync(string serviceCode);
Task<AppConfigResponseDto> GetPrivacyAsync(string serviceCode);
}

View File

@ -0,0 +1,43 @@
using SPMS.Application.DTOs.AppConfig;
using SPMS.Application.Interfaces;
using SPMS.Domain.Common;
using SPMS.Domain.Exceptions;
using SPMS.Domain.Interfaces;
namespace SPMS.Application.Services;
public class AppConfigService : IAppConfigService
{
private readonly IAppConfigRepository _appConfigRepository;
private readonly IServiceRepository _serviceRepository;
public AppConfigService(IAppConfigRepository appConfigRepository, IServiceRepository serviceRepository)
{
_appConfigRepository = appConfigRepository;
_serviceRepository = serviceRepository;
}
public async Task<AppConfigResponseDto> GetTermsAsync(string serviceCode)
{
return await GetConfigUrlAsync(serviceCode, "terms_url");
}
public async Task<AppConfigResponseDto> GetPrivacyAsync(string serviceCode)
{
return await GetConfigUrlAsync(serviceCode, "privacy_url");
}
private async Task<AppConfigResponseDto> GetConfigUrlAsync(string serviceCode, string configKey)
{
var service = await _serviceRepository.GetByServiceCodeAsync(serviceCode);
if (service == null)
throw new SpmsException(ErrorCodes.NotFound, "존재하지 않는 서비스입니다.", 404);
var config = await _appConfigRepository.GetByKeyAsync(service.Id, configKey);
return new AppConfigResponseDto
{
Url = config?.ConfigValue
};
}
}

View File

@ -0,0 +1,8 @@
using SPMS.Domain.Entities;
namespace SPMS.Domain.Interfaces;
public interface IAppConfigRepository : IRepository<AppConfig>
{
Task<AppConfig?> GetByKeyAsync(long serviceId, string configKey);
}

View File

@ -30,6 +30,7 @@ public static class DependencyInjection
services.AddScoped<INoticeRepository, NoticeRepository>();
services.AddScoped<IBannerRepository, BannerRepository>();
services.AddScoped<IFaqRepository, FaqRepository>();
services.AddScoped<IAppConfigRepository, AppConfigRepository>();
// External Services
services.AddScoped<IJwtService, JwtService>();

View File

@ -0,0 +1,15 @@
using Microsoft.EntityFrameworkCore;
using SPMS.Domain.Entities;
using SPMS.Domain.Interfaces;
namespace SPMS.Infrastructure.Persistence.Repositories;
public class AppConfigRepository : Repository<AppConfig>, IAppConfigRepository
{
public AppConfigRepository(AppDbContext context) : base(context) { }
public async Task<AppConfig?> GetByKeyAsync(long serviceId, string configKey)
{
return await _dbSet.FirstOrDefaultAsync(c => c.ServiceId == serviceId && c.ConfigKey == configKey);
}
}