From b2b1ebe7947b2cf761f1852f829b56045ecb19a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D1=82=D0=BE=D0=BD?= Date: Sun, 21 Sep 2025 10:43:54 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=87=D0=B0=D1=8F=20?= =?UTF-8?q?=D1=81=D0=B1=D0=BE=D1=80=D0=BA=D0=B0=20=D0=B2=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=BE=D0=B3=D0=BE=20executor'=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- src/endpoints_handlers/AuthLoginExecutor.h | 8 ++++---- src/endpoints_handlers/AuthRegistrationExecutor.h | 4 ++-- src/endpoints_handlers/HandleRequest.h | 7 +++++-- src/endpoints_handlers/RootExecutor.h | 8 ++++---- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index adbdb6f..c3010e6 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ - ~~Пройтись по коду и максимально наставить const~~ - Указать возможные исключения в интерфейсах DAO - Вынести User в структуру. Hashed Password структура должна изначально состоять в другой структуре -- SharedPtr - передавать по константной ссылке. +- ~~SharedPtr - передавать по константной ссылке.~~ - Сделать интеграционный тест по ручкам # UseCase'ы приложения: diff --git a/src/endpoints_handlers/AuthLoginExecutor.h b/src/endpoints_handlers/AuthLoginExecutor.h index f6b4a51..bf66fb1 100644 --- a/src/endpoints_handlers/AuthLoginExecutor.h +++ b/src/endpoints_handlers/AuthLoginExecutor.h @@ -17,13 +17,13 @@ template class AuthLoginExecutor : public IExecutor { mysqlx::Session& session_; - std::shared_ptr user_dao_; - std::shared_ptr auth_dao_; + const std::shared_ptr& user_dao_; + const std::shared_ptr& auth_dao_; public: AuthLoginExecutor(mysqlx::Session& session, - std::shared_ptr user_dao, - std::shared_ptr auth_dao) + const std::shared_ptr& user_dao, + const std::shared_ptr& auth_dao) : session_(session), user_dao_(user_dao), auth_dao_(auth_dao) { } diff --git a/src/endpoints_handlers/AuthRegistrationExecutor.h b/src/endpoints_handlers/AuthRegistrationExecutor.h index aee194d..2532b6b 100644 --- a/src/endpoints_handlers/AuthRegistrationExecutor.h +++ b/src/endpoints_handlers/AuthRegistrationExecutor.h @@ -15,11 +15,11 @@ template class AuthRegistrationExecutor : public IExecutor { mysqlx::Session& session_; - std::shared_ptr user_dao_; + const std::shared_ptr& user_dao_; public: AuthRegistrationExecutor(mysqlx::Session& session, - std::shared_ptr user_dao) + const std::shared_ptr& user_dao) : session_(session), user_dao_(user_dao) { } diff --git a/src/endpoints_handlers/HandleRequest.h b/src/endpoints_handlers/HandleRequest.h index 860faf6..3f3b008 100644 --- a/src/endpoints_handlers/HandleRequest.h +++ b/src/endpoints_handlers/HandleRequest.h @@ -17,10 +17,13 @@ void HandleRequest( boost::beast::http::request>&& req, Send&& send) { + static std::shared_ptr user_dao = std::make_shared(GetMySqlSession()); + static std::shared_ptr auth_dao = std::make_shared(GetMySqlSession()); + static RootExecutor root_executor( GetMySqlSession(), - std::make_shared(GetMySqlSession()), - std::make_shared(GetMySqlSession()) + user_dao, + auth_dao ); root_executor(doc_root, std::move(req), std::forward(send)); diff --git a/src/endpoints_handlers/RootExecutor.h b/src/endpoints_handlers/RootExecutor.h index 03714ae..9adecc8 100644 --- a/src/endpoints_handlers/RootExecutor.h +++ b/src/endpoints_handlers/RootExecutor.h @@ -28,14 +28,14 @@ class RootExecutor private: RoutesPathes routes_pathes_; mysqlx::Session& session_; - std::shared_ptr user_dao_; - std::shared_ptr auth_dao_; + const std::shared_ptr& user_dao_; + const std::shared_ptr& auth_dao_; public: RootExecutor( mysqlx::Session& session, - std::shared_ptr user_dao, - std::shared_ptr auth_dao) : + const std::shared_ptr& user_dao, + const std::shared_ptr& auth_dao) : session_(session), user_dao_(user_dao), auth_dao_(auth_dao) { routes_pathes_["/api/v1/Auth/Register"] = std::make_unique(