namespace TaxBaik.Application.Services; using TaxBaik.Domain.Entities; using TaxBaik.Domain.Interfaces; public class FaqService(IFaqRepository repository) { public static readonly string[] Categories = ["기장·세금신고", "부동산", "증여·상속", "기타"]; public async Task> GetActiveAsync(CancellationToken ct = default) => await repository.GetActiveAsync(ct); public async Task> GetAllAsync(CancellationToken ct = default) => await repository.GetAllAsync(ct); public async Task GetByIdAsync(int id, CancellationToken ct = default) => await repository.GetByIdAsync(id, ct); public async Task CreateAsync(Faq faq, CancellationToken ct = default) { Validate(faq); return await repository.CreateAsync(faq, ct); } public async Task UpdateAsync(Faq faq, CancellationToken ct = default) { Validate(faq); await repository.UpdateAsync(faq, ct); } public async Task DeleteAsync(int id, CancellationToken ct = default) => await repository.DeleteAsync(id, ct); private static void Validate(Faq faq) { if (string.IsNullOrWhiteSpace(faq.Question)) throw new ValidationException("질문을 입력하세요."); if (string.IsNullOrWhiteSpace(faq.Answer)) throw new ValidationException("답변을 입력하세요."); } }