generated from Sithas/conan_template
Внесение в контроллеры Session MySQL и MySQLUserDAO
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include <optional>
|
||||
#pragma once
|
||||
|
||||
#include "../entities/User.h"
|
||||
|
||||
|
||||
@@ -1,13 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <mysqlx/xdevapi.h>
|
||||
#include <mysqlx/common/api.h>
|
||||
|
||||
#include "IExecutor.h"
|
||||
#include "../DAO/IUserDAO.h"
|
||||
|
||||
namespace uad
|
||||
{
|
||||
template <class Body, class Allocator, class ResponseType>
|
||||
class AuthRegistrationExecutor : public IExecutor<Body, Allocator, ResponseType>
|
||||
{
|
||||
mysqlx::Session& session_;
|
||||
std::shared_ptr<IUserDAO> user_dao_;
|
||||
|
||||
public:
|
||||
AuthRegistrationExecutor(mysqlx::Session& session,
|
||||
std::shared_ptr<IUserDAO> user_dao)
|
||||
: session_(session), user_dao_(user_dao)
|
||||
{
|
||||
}
|
||||
|
||||
boost::beast::http::response<ResponseType> operator ()(
|
||||
boost::beast::http::request<Body, boost::beast::http::basic_fields<Allocator>>&& req
|
||||
) override
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <boost/beast.hpp>
|
||||
|
||||
#include "Controller.h"
|
||||
#include "../db/mysql_connector.h"
|
||||
#include "../DAO/IUserDAO.h"
|
||||
#include "AuthRegistrationExecutor.h"
|
||||
#include "RootExecutor.h"
|
||||
#include "../DAO/MySQLUserDAO.h"
|
||||
|
||||
namespace uad
|
||||
{
|
||||
@@ -16,7 +16,9 @@ void HandleRequest(
|
||||
boost::beast::http::request<Body, boost::beast::http::basic_fields<Allocator>>&& req,
|
||||
Send&& send)
|
||||
{
|
||||
static RootExecutor<Body, Allocator, boost::beast::http::string_body, Send> root_executor;
|
||||
static RootExecutor<Body, Allocator, boost::beast::http::string_body, Send> root_executor(
|
||||
GetMySqlSession(), std::make_shared<MySQLUserDAO>(GetMySqlSession())
|
||||
);
|
||||
|
||||
root_executor(doc_root, std::move(req), std::forward<Send>(send));
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "IController.h"
|
||||
#include "Controller.h"
|
||||
#include "AuthRegistrationExecutor.h"
|
||||
#include "../DAO/IUserDAO.h"
|
||||
#include "./../helpers/helpers.h"
|
||||
|
||||
namespace uad
|
||||
@@ -22,13 +23,16 @@ class RootExecutor
|
||||
|
||||
private:
|
||||
RoutesPathes routes_pathes_;
|
||||
mysqlx::Session& session_;
|
||||
std::shared_ptr<IUserDAO> user_dao_;
|
||||
|
||||
public:
|
||||
RootExecutor()
|
||||
RootExecutor(mysqlx::Session& session, std::shared_ptr<IUserDAO> user_dao)
|
||||
: session_(session), user_dao_(user_dao)
|
||||
{
|
||||
routes_pathes_["/api/v1/Auth/Register"] = std::make_unique<RouteController>(
|
||||
typename RouteController::HTTPMethodsToExecutors{
|
||||
{boost::beast::http::verb::get, std::make_shared<RouteAuthRegistrationExecutor>()}
|
||||
{boost::beast::http::verb::post, std::make_shared<RouteAuthRegistrationExecutor>(session_, user_dao_)}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace uad
|
||||
|
||||
Reference in New Issue
Block a user