feat(admin): stabilize blog and admin patterns
TaxBaik CI/CD / build-and-deploy (push) Has been cancelled

This commit is contained in:
2026-07-02 10:46:27 +09:00
parent b3cab87539
commit cb47349a25
67 changed files with 1354 additions and 486 deletions
@@ -15,7 +15,7 @@ public class BlogPostRepository(IDbConnectionFactory connectionFactory) : BaseRe
bp.is_published, bp.created_at, bp.updated_at, c.name AS category_name
FROM blog_posts bp
LEFT JOIN categories c ON bp.category_id = c.id
WHERE bp.id = @Id",
WHERE bp.id = @Id AND bp.deleted_at IS NULL",
new { Id = id });
}
@@ -28,7 +28,7 @@ public class BlogPostRepository(IDbConnectionFactory connectionFactory) : BaseRe
bp.is_published, bp.created_at, bp.updated_at, c.name AS category_name
FROM blog_posts bp
LEFT JOIN categories c ON bp.category_id = c.id
WHERE bp.slug = @Slug AND bp.is_published = TRUE",
WHERE bp.slug = @Slug AND bp.is_published = TRUE AND bp.deleted_at IS NULL",
new { Slug = slug });
}
@@ -44,12 +44,12 @@ public class BlogPostRepository(IDbConnectionFactory connectionFactory) : BaseRe
bp.is_published, bp.created_at, bp.updated_at, c.name AS category_name
FROM blog_posts bp
LEFT JOIN categories c ON bp.category_id = c.id
WHERE bp.is_published = TRUE AND (@CategoryId::int IS NULL OR bp.category_id = @CategoryId)
WHERE bp.is_published = TRUE AND bp.deleted_at IS NULL AND (@CategoryId::int IS NULL OR bp.category_id = @CategoryId)
ORDER BY bp.published_at DESC
LIMIT @PageSize OFFSET @Offset;
SELECT COUNT(*) FROM blog_posts
WHERE is_published = TRUE AND (@CategoryId::int IS NULL OR category_id = @CategoryId);",
WHERE is_published = TRUE AND deleted_at IS NULL AND (@CategoryId::int IS NULL OR category_id = @CategoryId);",
new { CategoryId = categoryId, PageSize = pageSize, Offset = offset });
var items = (await reader.ReadAsync<BlogPost>()).ToList();
@@ -67,7 +67,7 @@ public class BlogPostRepository(IDbConnectionFactory connectionFactory) : BaseRe
bp.is_published, bp.created_at, bp.updated_at, c.name AS category_name
FROM blog_posts bp
LEFT JOIN categories c ON bp.category_id = c.id
WHERE bp.is_published = TRUE AND c.slug = @CategorySlug
WHERE bp.is_published = TRUE AND bp.deleted_at IS NULL AND c.slug = @CategorySlug
ORDER BY bp.published_at DESC
LIMIT @Limit",
new { CategorySlug = categorySlug, Limit = limit });
@@ -82,6 +82,7 @@ public class BlogPostRepository(IDbConnectionFactory connectionFactory) : BaseRe
bp.is_published, bp.created_at, bp.updated_at, c.name AS category_name
FROM blog_posts bp
LEFT JOIN categories c ON bp.category_id = c.id
WHERE bp.deleted_at IS NULL
ORDER BY bp.created_at DESC");
}
@@ -97,10 +98,11 @@ public class BlogPostRepository(IDbConnectionFactory connectionFactory) : BaseRe
bp.is_published, bp.created_at, bp.updated_at, c.name AS category_name
FROM blog_posts bp
LEFT JOIN categories c ON bp.category_id = c.id
WHERE bp.deleted_at IS NULL
ORDER BY bp.created_at DESC
LIMIT @PageSize OFFSET @Offset;
SELECT COUNT(*) FROM blog_posts;",
SELECT COUNT(*) FROM blog_posts WHERE deleted_at IS NULL;",
new { PageSize = pageSize, Offset = offset });
var items = (await reader.ReadAsync<BlogPost>()).ToList();
@@ -130,19 +132,26 @@ public class BlogPostRepository(IDbConnectionFactory connectionFactory) : BaseRe
tags = @Tags, author_id = @AuthorId, published_at = @PublishedAt,
seo_title = @SeoTitle, seo_description = @SeoDescription,
thumbnail_url = @ThumbnailUrl, is_published = @IsPublished, updated_at = NOW()
WHERE id = @Id",
WHERE id = @Id AND deleted_at IS NULL",
post);
}
public async Task DeleteAsync(int id, CancellationToken cancellationToken = default)
{
await ArchiveAsync(id, cancellationToken);
}
public async Task ArchiveAsync(int id, CancellationToken cancellationToken = default)
{
using var conn = Conn();
await conn.ExecuteAsync("DELETE FROM blog_posts WHERE id = @Id", new { Id = id });
await conn.ExecuteAsync(
"UPDATE blog_posts SET deleted_at = NOW(), updated_at = NOW() WHERE id = @Id AND deleted_at IS NULL",
new { Id = id });
}
public async Task IncrementViewCountAsync(int id, CancellationToken cancellationToken = default)
{
using var conn = Conn();
await conn.ExecuteAsync("UPDATE blog_posts SET view_count = view_count + 1 WHERE id = @Id", new { Id = id });
await conn.ExecuteAsync("UPDATE blog_posts SET view_count = view_count + 1 WHERE id = @Id AND deleted_at IS NULL", new { Id = id });
}
}