generated from Sithas/conan_template
Бор DAO и User Entity
This commit is contained in:
@@ -37,6 +37,11 @@ add_executable(App ./src/main.cpp
|
|||||||
./src/listener/Listener.cpp
|
./src/listener/Listener.cpp
|
||||||
./src/db/mysql_connector.cpp
|
./src/db/mysql_connector.cpp
|
||||||
./src/db/mysql_connector.h
|
./src/db/mysql_connector.h
|
||||||
|
./src/DAO/IUserDAO.h
|
||||||
|
./src/entities/User.cpp
|
||||||
|
./src/entities/User.h
|
||||||
|
./src/DAO/MySQLUserDAO.cpp
|
||||||
|
./src/DAO/MySQLUserDAO.h
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(App PRIVATE Boost::boost Threads::Threads mysql::concpp)
|
target_link_libraries(App PRIVATE Boost::boost Threads::Threads mysql::concpp)
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#include <cstdint>
|
||||||
|
#include <vector>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
|
#include "../entities/User.h"
|
||||||
|
|
||||||
|
namespace uad
|
||||||
|
{
|
||||||
|
class IUserDAO
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual std::string Create(const User& created_user) = 0;
|
||||||
|
|
||||||
|
virtual std::optional<User> GetByGUID(std::string guid) = 0;
|
||||||
|
|
||||||
|
virtual std::vector<User> GetAll() = 0;
|
||||||
|
|
||||||
|
virtual bool Update(const User& u) = 0;
|
||||||
|
|
||||||
|
virtual bool Delete(std::string id) = 0;
|
||||||
|
|
||||||
|
virtual ~IUserDAO() = default;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
#include "MySQLUserDAO.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace string_literals;
|
||||||
|
|
||||||
|
namespace uad
|
||||||
|
{
|
||||||
|
MySQLUserDAO::MySQLUserDAO(mysqlx::Session& session): session_(session)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
string MySQLUserDAO::Create(const User& created_user)
|
||||||
|
{
|
||||||
|
return ""s;
|
||||||
|
}
|
||||||
|
|
||||||
|
optional<User> MySQLUserDAO::GetByGUID(string guid)
|
||||||
|
{
|
||||||
|
return nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<User> MySQLUserDAO::GetAll()
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MySQLUserDAO::Update(const User& u)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MySQLUserDAO::Delete(string id)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} // uad
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
#include <mysqlx/xdevapi.h>
|
||||||
|
|
||||||
|
#include "IUserDAO.h"
|
||||||
|
|
||||||
|
namespace uad
|
||||||
|
{
|
||||||
|
class MySQLUserDAO : public IUserDAO
|
||||||
|
{
|
||||||
|
mysqlx::Session& session_;
|
||||||
|
public:
|
||||||
|
explicit MySQLUserDAO(mysqlx::Session& session);
|
||||||
|
|
||||||
|
std::string Create(const User& created_user);
|
||||||
|
|
||||||
|
std::optional<User> GetByGUID(std::string guid);
|
||||||
|
|
||||||
|
std::vector<User> GetAll();
|
||||||
|
|
||||||
|
bool Update(const User& u);
|
||||||
|
|
||||||
|
bool Delete(std::string id);
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
//
|
||||||
|
// Created by Антон on 25.08.2025.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "User.h"
|
||||||
|
|
||||||
|
namespace uad
|
||||||
|
{
|
||||||
|
const std::string& User::GetGUID() const noexcept
|
||||||
|
{
|
||||||
|
return guid_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string& User::GetLogin() const noexcept
|
||||||
|
{
|
||||||
|
return login_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void User::SetLogin(const std::string& login)
|
||||||
|
{
|
||||||
|
login_ = login;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string& User::GetHashedPassword() const noexcept
|
||||||
|
{
|
||||||
|
return hashed_password_;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace uad
|
||||||
|
{
|
||||||
|
class User
|
||||||
|
{
|
||||||
|
std::string guid_;
|
||||||
|
std::string login_;
|
||||||
|
std::string hashed_password_;
|
||||||
|
public:
|
||||||
|
[[nodiscard]] const std::string& GetGUID() const noexcept;
|
||||||
|
|
||||||
|
[[nodiscard]] const std::string& GetLogin() const noexcept;
|
||||||
|
|
||||||
|
void SetLogin(const std::string& login);
|
||||||
|
|
||||||
|
[[nodiscard]] const std::string& GetHashedPassword() const noexcept;
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user