generated from Sithas/conan_template
База для ручки PostUserMedicationsExecutor.h
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
#include "MySQLDiariesDAO.h"
|
||||
|
||||
namespace uad
|
||||
{
|
||||
MySqlDiariesDAO::MySqlDiariesDAO(mysqlx::Session& session) : session_(session)
|
||||
{
|
||||
}
|
||||
|
||||
std::vector<diary_dto> MySqlDiariesDAO::GetDiariesByLogin(const std::string& login)
|
||||
{
|
||||
static const std::string query = R"(
|
||||
SELECT
|
||||
d.uuid,
|
||||
UNIX_TIMESTAMP(d.time) * 1000 AS time_ms,
|
||||
d.mania_level,
|
||||
d.depression_level,
|
||||
d.mood_level,
|
||||
d.activity_level,
|
||||
d.appetite_level,
|
||||
d.dream_level,
|
||||
d.anxiety_level,
|
||||
d.comment,
|
||||
d.user_treatment_schemes_uuid
|
||||
FROM up_and_down.users u
|
||||
JOIN up_and_down.diaries d
|
||||
ON d.user_uuid = u.uuid
|
||||
WHERE u.login = ?
|
||||
ORDER BY d.time ASC
|
||||
)";
|
||||
|
||||
mysqlx::SqlResult result = session_
|
||||
.sql(query)
|
||||
.bind(login)
|
||||
.execute();
|
||||
|
||||
std::vector<diary_dto> diaries;
|
||||
diaries.reserve(result.count());
|
||||
|
||||
for (const mysqlx::Row& row : result)
|
||||
{
|
||||
diary_dto dto;
|
||||
|
||||
dto.uuid = row[0].get<std::string>();
|
||||
dto.time_ms = row[1].get<std::int64_t>();
|
||||
dto.mania_level = row[2].get<int>();
|
||||
dto.depression_level = row[3].get<int>();
|
||||
dto.mood_level = row[4].get<int>();
|
||||
dto.activity_level = row[5].get<int>();
|
||||
dto.appetite_level = row[6].get<int>();
|
||||
dto.dream_level = row[7].get<int>();
|
||||
dto.anxiety_level = row[8].get<int>();
|
||||
|
||||
dto.comment =
|
||||
row[9].isNull() ? "" : row[9].get<std::string>();
|
||||
|
||||
dto.user_treatment_scheme_uuid =
|
||||
row[10].isNull() ? "" : row[10].get<std::string>();
|
||||
|
||||
diaries.push_back(std::move(dto));
|
||||
}
|
||||
|
||||
return diaries;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user