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 GetByUsernameAsync(string username) { using var conn = _connectionFactory.CreateConnection(); return await conn.QueryFirstOrDefaultAsync( """ SELECT id, username, password_hash AS PasswordHash, last_login_at AS LastLoginAt, created_at AS CreatedAt FROM admin_users WHERE username = @username """, new { username }); } public async Task GetByIdAsync(int id) { using var conn = _connectionFactory.CreateConnection(); return await conn.QueryFirstOrDefaultAsync( """ SELECT id, username, password_hash AS PasswordHash, last_login_at AS LastLoginAt, created_at AS CreatedAt 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 }); } }