42 lines
1.3 KiB
C#
42 lines
1.3 KiB
C#
using SPMS.Application.DTOs.Faq;
|
|
using SPMS.Application.Interfaces;
|
|
using SPMS.Domain.Common;
|
|
using SPMS.Domain.Exceptions;
|
|
using SPMS.Domain.Interfaces;
|
|
|
|
namespace SPMS.Application.Services;
|
|
|
|
public class FaqService : IFaqService
|
|
{
|
|
private readonly IFaqRepository _faqRepository;
|
|
private readonly IServiceRepository _serviceRepository;
|
|
|
|
public FaqService(IFaqRepository faqRepository, IServiceRepository serviceRepository)
|
|
{
|
|
_faqRepository = faqRepository;
|
|
_serviceRepository = serviceRepository;
|
|
}
|
|
|
|
public async Task<FaqListResponseDto> GetListAsync(string serviceCode, FaqListRequestDto request)
|
|
{
|
|
var service = await _serviceRepository.GetByServiceCodeAsync(serviceCode);
|
|
if (service == null)
|
|
throw new SpmsException(ErrorCodes.NotFound, "존재하지 않는 서비스입니다.", 404);
|
|
|
|
var items = await _faqRepository.GetActiveListAsync(service.Id, request.Category);
|
|
|
|
return new FaqListResponseDto
|
|
{
|
|
Items = items.Select(f => new FaqItemDto
|
|
{
|
|
FaqId = f.Id,
|
|
Category = f.Category,
|
|
Question = f.Question,
|
|
Answer = f.Answer,
|
|
SortOrder = f.SortOrder
|
|
}).ToList(),
|
|
TotalCount = items.Count
|
|
};
|
|
}
|
|
}
|