Бор DAO и User Entity

This commit is contained in:
Антон
2025-08-25 17:22:03 +03:00
parent 5faf10be72
commit 96594db979
6 changed files with 135 additions and 0 deletions
+24
View File
@@ -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;
};
}
+36
View File
@@ -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
+23
View File
@@ -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);
};
}