From 4b83a29f786c5f96b471e870807ff0dba98d9c4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D1=82=D0=BE=D0=BD?= Date: Mon, 1 Sep 2025 10:48:47 +0300 Subject: [PATCH] =?UTF-8?q?DAO=20-=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0?= =?UTF-8?q?=D0=B5=D1=82=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/DAO/MySQLUserDAO.cpp | 11 ++++++++++- src/endpoints_handlers/AuthRegistrationExecutor.h | 9 +++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/DAO/MySQLUserDAO.cpp b/src/DAO/MySQLUserDAO.cpp index c140502..5421a8c 100644 --- a/src/DAO/MySQLUserDAO.cpp +++ b/src/DAO/MySQLUserDAO.cpp @@ -93,7 +93,16 @@ pair> MySQLUserDAO::GetAll(size_t limit, size_t offset) bool MySQLUserDAO::Update(const User& u) { - return false; + auto schema = session_.getSchema("up_and_down"); + auto table = schema.getTable("users"); + mysqlx::Result res = table.update() + .set("login", u.GetLogin()) + .set("hashed_password", u.GetHashedPassword()) + .where("uuid = :uuid") + .bind("uuid", u.GetUUID()) + .execute(); + + return res.getAffectedItemsCount() > 0; } bool MySQLUserDAO::Delete(string id) diff --git a/src/endpoints_handlers/AuthRegistrationExecutor.h b/src/endpoints_handlers/AuthRegistrationExecutor.h index aee194d..6670aa0 100644 --- a/src/endpoints_handlers/AuthRegistrationExecutor.h +++ b/src/endpoints_handlers/AuthRegistrationExecutor.h @@ -97,6 +97,15 @@ public: const auto uuid_stringified = user_dao_->Create(user); + { + User updated_user; + updated_user.SetUUID("c792bbe6-2bf2-4fe0-a781-ba96bfeaa3b6"); + updated_user.SetLogin("login56"); + updated_user.SetPassword("Qwerty123456"); + + user_dao_->Update(updated_user); + } + http::response res{ http::status::created, req.version() };