Compare commits

...

2 Commits

Author SHA1 Message Date
kjh2064 ad55bd1884 fix(blog): add restore path for archived posts
TaxBaik CI/CD / build-and-deploy (push) Successful in 4m57s
2026-07-02 11:05:53 +09:00
kjh2064 e0b8d4e370 fix(home): keep blog entry visible when empty 2026-07-02 11:03:37 +09:00
7 changed files with 47 additions and 0 deletions
@@ -112,6 +112,14 @@ public class BlogServiceTests
public Task ArchiveAsync(int id, CancellationToken cancellationToken = default) => DeleteAsync(id, cancellationToken);
public Task RestoreAsync(int id, CancellationToken cancellationToken = default)
{
var post = Posts.FirstOrDefault(x => x.Id == id);
if (post != null)
post.DeletedAt = null;
return Task.CompletedTask;
}
public Task IncrementViewCountAsync(int id, CancellationToken cancellationToken = default) => Task.CompletedTask;
}
}
@@ -116,6 +116,12 @@ public class BlogService(IBlogPostRepository repository, IMemoryCache memoryCach
memoryCache.Remove(AdminDashboardService.CacheKey);
}
public async Task RestoreAsync(int id, CancellationToken ct = default)
{
await repository.RestoreAsync(id, ct);
memoryCache.Remove(AdminDashboardService.CacheKey);
}
public async Task IncrementViewCountAsync(int id, CancellationToken ct = default) =>
await repository.IncrementViewCountAsync(id, ct);
@@ -16,5 +16,6 @@ public interface IBlogPostRepository
Task UpdateAsync(BlogPost post, CancellationToken cancellationToken = default);
Task DeleteAsync(int id, CancellationToken cancellationToken = default);
Task ArchiveAsync(int id, CancellationToken cancellationToken = default);
Task RestoreAsync(int id, CancellationToken cancellationToken = default);
Task IncrementViewCountAsync(int id, CancellationToken cancellationToken = default);
}
@@ -149,6 +149,14 @@ public class BlogPostRepository(IDbConnectionFactory connectionFactory) : BaseRe
new { Id = id });
}
public async Task RestoreAsync(int id, CancellationToken cancellationToken = default)
{
using var conn = Conn();
await conn.ExecuteAsync(
"UPDATE blog_posts SET deleted_at = NULL, updated_at = NOW() WHERE id = @Id AND deleted_at IS NOT NULL",
new { Id = id });
}
public async Task IncrementViewCountAsync(int id, CancellationToken cancellationToken = default)
{
using var conn = Conn();
@@ -97,4 +97,12 @@ public class BlogController : ControllerBase
await _blogService.ArchiveAsync(id);
return NoContent();
}
[HttpPost("{id}/restore")]
[Authorize]
public async Task<IActionResult> Restore(int id)
{
await _blogService.RestoreAsync(id);
return NoContent();
}
}
+9
View File
@@ -263,6 +263,15 @@ else
<a href="/taxbaik/blog" class="btn btn-outline-primary btn-lg">전체 블로그 보기</a>
</div>
}
else
{
<div class="text-center py-5">
<div class="mb-3" style="font-size: 3rem;">📝</div>
<h3 class="h5 mb-2">현재 표시할 블로그 글이 없습니다.</h3>
<p class="text-muted mb-4">최신 세무 정보는 블로그에서 확인할 수 있습니다.</p>
<a href="/taxbaik/blog" class="btn btn-outline-primary btn-lg">블로그 바로가기</a>
</div>
}
</div>
</section>
+7
View File
@@ -0,0 +1,7 @@
-- Restore archived blog posts that were hidden by soft delete.
-- Use only when the goal is to bring back previously archived posts.
UPDATE blog_posts
SET deleted_at = NULL,
updated_at = NOW()
WHERE deleted_at IS NOT NULL;