Put Diary

This commit is contained in:
2026-01-25 15:08:30 +03:00
parent b3007c1471
commit e4104e9707
7 changed files with 186 additions and 9 deletions
+6
View File
@@ -17,6 +17,12 @@ public:
const diary_dto& dto
) const = 0;
virtual void UpdateDiary(
const std::string& user_uuid,
const std::string& diary_uuid,
const diary_dto& dto
) const = 0;
virtual ~IDiariesDAO() = default;
};
}
+42
View File
@@ -1,5 +1,7 @@
#include "MySQLDiariesDAO.h"
#include "../exceptions/session_exception.h"
namespace uad
{
MySqlDiariesDAO::MySqlDiariesDAO(mysqlx::Session& session) : session_(session)
@@ -107,4 +109,44 @@ void MySqlDiariesDAO::СreateDiary(const std::string& user_uuid, const diary_dto
stmt.execute();
}
void MySqlDiariesDAO::UpdateDiary(
const std::string& user_uuid,
const std::string& diary_uuid,
const diary_dto& dto) const
{
auto stmt = session_.sql(R"(
UPDATE `up_and_down`.`diaries`
SET
mania_level = ?,
depression_level = ?,
mood_level = ?,
activity_level = ?,
appetite_level = ?,
dream_level = ?,
anxiety_level = ?,
comment = ?,
user_treatment_schemes_uuid = ?
WHERE uuid = ?
)");
stmt.bind(
dto.mania_level,
dto.depression_level,
dto.mood_level,
dto.activity_level,
dto.appetite_level,
dto.dream_level,
dto.anxiety_level,
dto.comment,
dto.user_treatment_scheme_uuid,
dto.uuid
);
auto res = stmt.execute();
if (res.getAffectedItemsCount() == 0) {
throw session_exception(boost::beast::http::status::not_found, "Diary not found");
}
}
}
+6
View File
@@ -21,5 +21,11 @@ public:
const std::string& user_uuid,
const diary_dto& dto
) const override;
void UpdateDiary(
const std::string& user_uuid,
const std::string& diary_uuid,
const diary_dto& dto
) const override;
};
}