generated from Sithas/conan_template
Корректный, хоть и грубый захват JSON'а
This commit is contained in:
@@ -23,6 +23,18 @@ optional<User> MySQLUserDAO::GetByGUID(string guid)
|
|||||||
|
|
||||||
std::optional<User> MySQLUserDAO::GetByLogin(std::string login)
|
std::optional<User> MySQLUserDAO::GetByLogin(std::string login)
|
||||||
{
|
{
|
||||||
|
auto sql_result = session_.sql("SELECT * FROM `up_and_down`.`users` WHERE (login = '" + login + "') LIMIT 1;"s).execute();
|
||||||
|
list<mysqlx::Row> rows = sql_result.fetchAll();
|
||||||
|
|
||||||
|
if (rows.size())
|
||||||
|
{
|
||||||
|
auto row_data = *rows.begin();
|
||||||
|
|
||||||
|
string replicated_login = row_data[1].get<string>();
|
||||||
|
|
||||||
|
cout << "SUCCESS!" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
return nullopt;
|
return nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,14 +33,16 @@ public:
|
|||||||
auto body = req.body();
|
auto body = req.body();
|
||||||
object json_as_object = json::parse(body).as_object();
|
object json_as_object = json::parse(body).as_object();
|
||||||
|
|
||||||
std::string login = serialize(json_as_object.at("login").as_string());
|
std::string login = json_as_object.at("login").as_string().c_str();
|
||||||
std::string password = serialize(json_as_object.at("password").as_string());
|
std::string password = json_as_object.at("password").as_string().c_str();
|
||||||
|
|
||||||
User user;
|
User user;
|
||||||
|
|
||||||
user.SetLogin(login);
|
user.SetLogin(login);
|
||||||
user.SetPassword(password);
|
user.SetPassword(password);
|
||||||
|
|
||||||
|
user_dao_->GetByLogin(login);
|
||||||
|
|
||||||
http::response<ResponseType> res{
|
http::response<ResponseType> res{
|
||||||
http::status::ok, req.version()
|
http::status::ok, req.version()
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -45,21 +45,6 @@ int main(int argc, char* argv[])
|
|||||||
string mysql_credentials = argv[5];
|
string mysql_credentials = argv[5];
|
||||||
|
|
||||||
uad::SetMySqlSession(new mysqlx::Session(mysql_credentials));
|
uad::SetMySqlSession(new mysqlx::Session(mysql_credentials));
|
||||||
auto& session = uad::GetMySqlSession();
|
|
||||||
|
|
||||||
auto schema = session.getSchema("up_and_down");
|
|
||||||
|
|
||||||
auto collections_names = schema.getCollectionNames();
|
|
||||||
auto users_collection = schema.getCollection("users");
|
|
||||||
auto users_collection_2 = session.sql("SELECT * FROM up_and_down.users;").execute();
|
|
||||||
|
|
||||||
auto users_rows = users_collection_2.fetchAll();
|
|
||||||
|
|
||||||
auto rows = *users_rows.begin();
|
|
||||||
|
|
||||||
const auto& user_guid = static_cast<string>(rows.get(0));
|
|
||||||
const auto& user_login = static_cast<string>(rows.get(1));
|
|
||||||
const auto& user_hashed_password = static_cast<string>(rows.get(2));
|
|
||||||
|
|
||||||
net::io_context ioc{threads};
|
net::io_context ioc{threads};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user