추가: 초기 관리자 계정 및 블로그 포스트 5개
- 초기 관리자: admin / admin123 - 블로그 포스트 5개 자동 생성 - AdminUserRepository 구현 - CreateBlogPostDto 추가 Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using Dapper;
|
||||
using TaxBaik.Domain.Entities;
|
||||
using TaxBaik.Domain.Interfaces;
|
||||
|
||||
namespace TaxBaik.Infrastructure.Repositories;
|
||||
|
||||
public class AdminUserRepository : BaseRepository, IAdminUserRepository
|
||||
{
|
||||
public AdminUserRepository(IDbConnectionFactory connectionFactory) : base(connectionFactory) { }
|
||||
|
||||
public async Task<AdminUser?> GetByUsernameAsync(string username)
|
||||
{
|
||||
using var conn = _connectionFactory.CreateConnection();
|
||||
return await conn.QueryFirstOrDefaultAsync<AdminUser>(
|
||||
"SELECT * FROM admin_users WHERE username = @username",
|
||||
new { username });
|
||||
}
|
||||
|
||||
public async Task<AdminUser?> GetByIdAsync(int id)
|
||||
{
|
||||
using var conn = _connectionFactory.CreateConnection();
|
||||
return await conn.QueryFirstOrDefaultAsync<AdminUser>(
|
||||
"SELECT * FROM admin_users WHERE id = @id",
|
||||
new { id });
|
||||
}
|
||||
|
||||
public async Task CreateAsync(AdminUser user)
|
||||
{
|
||||
using var conn = _connectionFactory.CreateConnection();
|
||||
await conn.ExecuteAsync(
|
||||
"INSERT INTO admin_users (username, password_hash, created_at) VALUES (@username, @passwordHash, NOW())",
|
||||
new { username = user.Username, passwordHash = user.PasswordHash });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user