8 #ifndef GETACCOUNTNUMBERREQUEST_H
9 #define GETACCOUNTNUMBERREQUEST_H
47 QJsonObject
execute(
const QJsonObject& jsonObj, QMutex& m)
override
49 QMutexLocker locker(&m);
56 response.insert(
"Response", 2);
59 if (jsonObj.contains(
"Data"))
61 QJsonObject dataObj = jsonObj[
"Data"].toObject();
63 if (dataObj.contains(
"email"))
65 email = dataObj.value(
"email").toString();
70 qCritical() <<
"Data not found";
87 result = dbManager->
select(
"A.account_number")
89 ->
join(
"JOIN Accounts A ON U.id = A.user_id")
90 ->
where(
"U.email =", email)
98 QJsonObject obj = result.
first();
100 data.insert(
"status",
int(
true));
101 data.insert(
"message",
"Account number found");
102 data.insert(
"account_number", obj.value(
"account_number").toInt());
104 response.insert(
"Data", data);
108 QJsonDocument responseDoc(response);
109 QByteArray responseData = responseDoc.toJson();
112 qDebug().noquote() <<
"<-- GetAccountNumber::Response :\n" << responseDoc.toJson(QJsonDocument::Indented);
This file contains the declaration of the Request class, which is an abstract base class for handling...
Manages database connections and SQL operations.
Definition: db.h:80
DatabaseManager * table(const QString &value)
Sets the table for the query.
Definition: db.cpp:115
DatabaseManager * where(const QString &value, const QVariant &val=QVariant())
Adds a WHERE clause to the query.
Definition: db.cpp:121
DbResult exec()
Executes the built query.
Definition: db.cpp:266
DatabaseManager * select(const QString &value)
Selects columns for the query.
Definition: db.cpp:107
DatabaseManager * join(const QString &value)
Adds a JOIN clause to the query.
Definition: db.cpp:188
The DbResult class represents a result set returned from a database query.
Definition: dbresult.h:24
QJsonObject first() const
Retrieves the first item in the result set.
Definition: dbresult.cpp:25
bool isEmpty() const
Checks if the result set is empty.
Definition: dbresult.cpp:20
The GetAccountNumberRequest class handles the retrieval of account numbers.
Definition: GetAccountNumberRequest.h:21
GetAccountNumberRequest()
Constructor for the GetAccountNumberRequest class.
Definition: GetAccountNumberRequest.h:31
QJsonObject execute(const QJsonObject &jsonObj, QMutex &m) override
Executes the request to get the account number.
Definition: GetAccountNumberRequest.h:47
The Request class is an abstract base class for handling different types of requests.
Definition: Request.h:25
QJsonObject CreateErrorResponse(QJsonObject &response, QJsonObject &dataObj, QString message)
Creates a generic error JSON response.
Definition: Request.h:90
QJsonObject CreateDBConnectionError(QJsonObject &response, QJsonObject &dataObj)
Creates a JSON response indicating a database connection error.
Definition: Request.h:65
bool isDBConnectionValid(DB::DatabaseManager *dbManager)
Checks if the database connection is valid.
Definition: Request.h:36
Database management classes for handling database connections and operations.