testapi
This commit is contained in:
1 parent
2db9525570
commit
5aca82244e
21 files changed
+545
-126
No files matched your search
@@ -0,0 +1,46 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MySqlConnector;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using uWine.Core.Domain.Entities;
|
||||
using uWine.Core.Domain.Repositories;
|
||||
|
||||
namespace uWine.Core.Infrastructure.Repository
|
||||
{
|
||||
|
||||
public class MariaDbUserRepository : MariaDbServerRepository, IUserRepository
|
||||
{
|
||||
public MariaDbUserRepository(IConfiguration configuration) : base(configuration)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public User UserById(int userId)
|
||||
{
|
||||
using (var conn = Connection())
|
||||
{
|
||||
conn.Open();
|
||||
var cmd = new MySqlCommand($@"SELECT u.id,
|
||||
username,
|
||||
u.role as role_id,
|
||||
r.role as name,
|
||||
description
|
||||
FROM t_users u
|
||||
JOIN t_role r on r.id = u.role
|
||||
WHERE u.id = @userId ", conn);
|
||||
cmd.Parameters.AddWithValue("userId", userId);
|
||||
using (var reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
return User.LoginUser(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new User();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user