44 lines
1.4 KiB
C#
44 lines
1.4 KiB
C#
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
|
|
};
|
|
}
|
|
}
|