개선: 배포 검증과 관리자 UX 안정화
TaxBaik Browser E2E / browser-e2e (push) Failing after 1m3s
TaxBaik CI/CD / build-and-deploy (push) Failing after 2m46s

This commit is contained in:
2026-06-27 20:57:09 +09:00
parent 64b08831e8
commit f29f2c3cff
51 changed files with 948 additions and 199 deletions
@@ -9,7 +9,9 @@ public static class DependencyInjection
{
services.AddScoped<BlogService>();
services.AddScoped<InquiryService>();
services.AddScoped<AdminDashboardService>();
services.AddScoped<IInquiryNotificationService, NoopInquiryNotificationService>();
services.AddScoped<SiteSettingService>();
services.AddScoped<CategoryService>();
return services;
}
@@ -0,0 +1,43 @@
namespace TaxBaik.Application.Services;
using Microsoft.Extensions.Caching.Memory;
using TaxBaik.Domain.Entities;
public record AdminDashboardSummary(
int ThisMonthInquiries,
int NewInquiries,
int TotalPosts,
int PublishedPosts,
IReadOnlyList<Inquiry> RecentInquiries);
public class AdminDashboardService(
InquiryService inquiryService,
BlogService blogService,
IMemoryCache memoryCache)
{
private static readonly TimeSpan CacheDuration = TimeSpan.FromSeconds(30);
public const string CacheKey = "admin-dashboard-summary";
public async Task<AdminDashboardSummary> GetSummaryAsync(CancellationToken ct = default)
{
if (memoryCache.TryGetValue(CacheKey, out AdminDashboardSummary? cached) && cached != null)
return cached;
var recentTask = inquiryService.GetPagedAsync(1, 5, ct: ct);
var thisMonthTask = inquiryService.CountThisMonthAsync(ct);
var newTask = inquiryService.CountByStatusAsync("new", ct);
var statsTask = blogService.GetStatsAsync(ct);
var (recentInquiries, _) = await recentTask;
var stats = await statsTask;
var summary = new AdminDashboardSummary(
ThisMonthInquiries: await thisMonthTask,
NewInquiries: await newTask,
TotalPosts: stats.TotalPosts,
PublishedPosts: stats.PublishedPosts,
RecentInquiries: recentInquiries.OrderByDescending(x => x.CreatedAt).Take(5).ToList());
memoryCache.Set(CacheKey, summary, CacheDuration);
return summary;
}
}
+18 -4
View File
@@ -5,7 +5,9 @@ using TaxBaik.Application.DTOs;
using TaxBaik.Domain.Entities;
using TaxBaik.Domain.Interfaces;
public class BlogService(IBlogPostRepository repository)
using Microsoft.Extensions.Caching.Memory;
public class BlogService(IBlogPostRepository repository, IMemoryCache memoryCache)
{
public async Task<BlogPost?> GetBySlugAsync(string slug, CancellationToken ct = default) =>
await repository.GetBySlugAsync(slug, ct);
@@ -20,6 +22,10 @@ public class BlogService(IBlogPostRepository repository)
public async Task<IEnumerable<BlogPost>> GetAllForAdminAsync(CancellationToken ct = default) =>
await repository.GetAllForAdminAsync(ct);
public async Task<(IEnumerable<BlogPost>, int)> GetAdminPagedAsync(
int page, int pageSize, CancellationToken ct = default) =>
await repository.GetAdminPagedAsync(NormalizePage(page), NormalizePageSize(pageSize), ct);
public async Task<int> CreateAsync(BlogPost post, CancellationToken ct = default)
{
ValidatePost(post);
@@ -27,7 +33,9 @@ public class BlogService(IBlogPostRepository repository)
post.Content = post.Content.Trim();
post.Slug = await GenerateUniqueSlugAsync(post.Title, ct: ct);
post.PublishedAt = post.IsPublished ? DateTime.UtcNow : null;
return await repository.CreateAsync(post, ct);
var result = await repository.CreateAsync(post, ct);
memoryCache.Remove(AdminDashboardService.CacheKey);
return result;
}
public async Task<BlogPost> CreateAsync(CreateBlogPostDto dto, CancellationToken ct = default)
@@ -51,8 +59,11 @@ public class BlogService(IBlogPostRepository repository)
return post;
}
public async Task UpdateAsync(BlogPost post, CancellationToken ct = default) =>
public async Task UpdateAsync(BlogPost post, CancellationToken ct = default)
{
await repository.UpdateAsync(post, ct);
memoryCache.Remove(AdminDashboardService.CacheKey);
}
public async Task<BlogPost?> UpdateAsync(int id, CreateBlogPostDto dto, CancellationToken ct = default)
{
@@ -77,8 +88,11 @@ public class BlogService(IBlogPostRepository repository)
return post;
}
public async Task DeleteAsync(int id, CancellationToken ct = default) =>
public async Task DeleteAsync(int id, CancellationToken ct = default)
{
await repository.DeleteAsync(id, ct);
memoryCache.Remove(AdminDashboardService.CacheKey);
}
public async Task IncrementViewCountAsync(int id, CancellationToken ct = default) =>
await repository.IncrementViewCountAsync(id, ct);
+16 -1
View File
@@ -1,11 +1,15 @@
namespace TaxBaik.Application.Services;
using System.Text.RegularExpressions;
using Microsoft.Extensions.Caching.Memory;
using TaxBaik.Domain.Entities;
using TaxBaik.Domain.Enums;
using TaxBaik.Domain.Interfaces;
public class InquiryService(IInquiryRepository repository, IInquiryNotificationService notificationService)
public class InquiryService(
IInquiryRepository repository,
IInquiryNotificationService notificationService,
IMemoryCache memoryCache)
{
private static readonly Regex PhoneRegex = new(@"^01[0-9]-\d{3,4}-\d{4}$");
@@ -36,6 +40,7 @@ public class InquiryService(IInquiryRepository repository, IInquiryNotificationS
var inquiryId = await repository.CreateAsync(inquiry, ct);
await notificationService.NotifyCreatedAsync(inquiryId, inquiry.Name, inquiry.Phone, inquiry.ServiceType, inquiry.Message, inquiry.IpAddress, inquiry.CreatedAt, ct);
memoryCache.Remove(AdminDashboardService.CacheKey);
return inquiryId;
}
@@ -46,6 +51,15 @@ public class InquiryService(IInquiryRepository repository, IInquiryNotificationS
int page, int pageSize, string? status = null, CancellationToken ct = default) =>
await repository.GetPagedAsync(NormalizePage(page), NormalizePageSize(pageSize), NormalizeOptionalStatus(status), ct);
public Task<int> CountAsync(CancellationToken ct = default)
=> repository.CountAsync(ct);
public Task<int> CountThisMonthAsync(CancellationToken ct = default)
=> repository.CountThisMonthAsync(ct);
public Task<int> CountByStatusAsync(string status, CancellationToken ct = default)
=> repository.CountByStatusAsync(status, ct);
public async Task UpdateStatusAsync(int id, string status, string? changedBy = null, CancellationToken ct = default)
{
if (!InquiryStatusMapper.TryParse(status, out var parsed))
@@ -60,6 +74,7 @@ public class InquiryService(IInquiryRepository repository, IInquiryNotificationS
await repository.UpdateStatusAsync(id, newStatus, ct);
await notificationService.NotifyStatusChangedAsync(id, inquiry.Name, inquiry.Phone, inquiry.ServiceType, previousStatus, newStatus, changedBy, ct);
memoryCache.Remove(AdminDashboardService.CacheKey);
}
private static int NormalizePage(int page) => Math.Max(1, page);
@@ -0,0 +1,23 @@
using TaxBaik.Domain.Entities;
using TaxBaik.Domain.Interfaces;
namespace TaxBaik.Application.Services;
public class SiteSettingService(ISiteSettingRepository repository)
{
public Task<IReadOnlyDictionary<string, string>> GetAllAsync(CancellationToken ct = default)
=> repository.GetAllAsync(ct);
public Task SaveAsync(string phone, string email, string kakaoUrl, string instagramUrl, CancellationToken ct = default)
{
var settings = new[]
{
new SiteSetting { Key = "PhoneNumber", Value = phone.Trim(), UpdatedAt = DateTime.UtcNow },
new SiteSetting { Key = "EmailAddress", Value = email.Trim(), UpdatedAt = DateTime.UtcNow },
new SiteSetting { Key = "KakaoChannelUrl", Value = kakaoUrl.Trim(), UpdatedAt = DateTime.UtcNow },
new SiteSetting { Key = "InstagramUrl", Value = instagramUrl.Trim(), UpdatedAt = DateTime.UtcNow },
};
return repository.UpsertAsync(settings, ct);
}
}
@@ -5,6 +5,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="10.0.0" />
</ItemGroup>
<PropertyGroup>