Добавление ДАО для использования в новом маршруте

This commit is contained in:
2026-01-06 09:52:30 +03:00
parent 8df55238be
commit 28a2f526bf
2 changed files with 14 additions and 3 deletions
+1 -1
View File
@@ -84,7 +84,7 @@ public:
typename RouteController::HTTPMethodsToExecutors{ typename RouteController::HTTPMethodsToExecutors{
{ {
boost::beast::http::verb::get, boost::beast::http::verb::get,
std::make_shared<RouteUserGetMedicationsExecutor>() std::make_shared<RouteUserGetMedicationsExecutor>(session_, auth_dao_, medications_dao_)
} }
} }
); );
@@ -6,7 +6,8 @@
#include <mysqlx/xdevapi.h> #include <mysqlx/xdevapi.h>
#include "IExecutor.h" #include "IExecutor.h"
#include "../DAO/IUserDAO.h" #include "../DAO/IAuthDAO.h"
#include "../DAO/IMedicationsDAO.h"
#include "../exceptions/session_exception.h" #include "../exceptions/session_exception.h"
namespace uad namespace uad
@@ -14,8 +15,18 @@ namespace uad
template <class Body, class Allocator, class ResponseType> template <class Body, class Allocator, class ResponseType>
class UserGetMedicationsExecutor : public IExecutor<Body, Allocator, ResponseType> class UserGetMedicationsExecutor : public IExecutor<Body, Allocator, ResponseType>
{ {
mysqlx::Session& session_;
const std::shared_ptr<IAuthDAO>& auth_dao_;
const std::shared_ptr<IMedicationsDAO>& medications_dao_;
public: public:
UserGetMedicationsExecutor() = default; UserGetMedicationsExecutor(
mysqlx::Session& session,
const std::shared_ptr<IAuthDAO>& auth_dao,
const std::shared_ptr<IMedicationsDAO>& medications_dao
): session_(session), auth_dao_(auth_dao), medications_dao_(medications_dao)
{
}
boost::beast::http::response<ResponseType> operator ()( boost::beast::http::response<ResponseType> operator ()(
boost::beast::http::request<Body, boost::beast::http::basic_fields<Allocator>>&& req boost::beast::http::request<Body, boost::beast::http::basic_fields<Allocator>>&& req