f4eeeb9ec0
- 초기 관리자: admin / admin123 - 블로그 포스트 5개 자동 생성 - AdminUserRepository 구현 - CreateBlogPostDto 추가 Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
35 lines
1.2 KiB
C#
35 lines
1.2 KiB
C#
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 });
|
|
}
|
|
}
|