![]() |
Banking_System_Server
1.0.0
Qt-based banking app for user/admin account management, transactions, secure server communication via PostgreSQL/Supabase.
|
The Request class is an abstract base class for handling different types of requests. More...
#include <Request.h>
Public Member Functions | |
virtual | ~Request () |
Virtual destructor for the Request class. More... | |
virtual QJsonObject | execute (const QJsonObject &jsonObj, QMutex &m)=0 |
Pure virtual method to execute a request. More... | |
Protected Member Functions | |
bool | isDBConnectionValid (DB::DatabaseManager *dbManager) |
Checks if the database connection is valid. More... | |
QJsonObject | CreateDBConnectionError (QJsonObject &response, QJsonObject &dataObj) |
Creates a JSON response indicating a database connection error. More... | |
QJsonObject | CreateErrorResponse (QJsonObject &response, QJsonObject &dataObj, QString message) |
Creates a generic error JSON response. More... | |
The Request class is an abstract base class for handling different types of requests.
This class provides the common interface and utility functions for processing various requests. It includes methods for checking database connectivity and creating error responses.
|
inlinevirtual |
Virtual destructor for the Request class.
Ensures proper cleanup of derived classes.
|
inlineprotected |
Creates a JSON response indicating a database connection error.
This method constructs a JSON response object with a status of false and a message indicating an internal server error related to database connectivity.
response | A reference to the QJsonObject that will be populated with the error response. |
dataObj | A reference to the QJsonObject that contains additional data about the error. |
Referenced by CreateNewUserRequest::execute(), DeleteUserRequest::execute(), GetAccountNumberRequest::execute(), GetBalanceRequest::execute(), GetDatabaseRequest::execute(), GetTransactionsHistoryRequest::execute(), LoginRequest::execute(), MakeTransactionRequest::execute(), UpdateEmailRequest::execute(), UpdatePasswordRequest::execute(), UpdateUserRequest::execute(), and UserInitRequest::execute().
|
inlineprotected |
Creates a generic error JSON response.
This method constructs a JSON response object with a status of false and a custom error message.
response | A reference to the QJsonObject that will be populated with the error response. |
dataObj | A reference to the QJsonObject that contains additional data about the error. |
message | A QString containing the error message to include in the response. |
Referenced by CreateNewUserRequest::execute(), DeleteUserRequest::execute(), GetAccountNumberRequest::execute(), GetBalanceRequest::execute(), GetDatabaseRequest::execute(), GetTransactionsHistoryRequest::execute(), LoginRequest::execute(), MakeTransactionRequest::execute(), UpdateEmailRequest::execute(), UpdatePasswordRequest::execute(), UpdateUserRequest::execute(), and UserInitRequest::execute().
|
pure virtual |
Pure virtual method to execute a request.
This method must be implemented by derived classes to handle specific types of requests.
jsonObj | A QJsonObject containing the request data. |
m | A QMutex reference for thread-safe operations. |
Implemented in UserInitRequest, UpdateUserRequest, UpdatePasswordRequest, UpdateEmailRequest, MakeTransactionRequest, LoginRequest, GetTransactionsHistoryRequest, GetDatabaseRequest, GetBalanceRequest, GetAccountNumberRequest, DeleteUserRequest, and CreateNewUserRequest.
|
inlineprotected |
Checks if the database connection is valid.
This method verifies that the database connection manager is not null and that the database is properly connected. Logs error messages if the connection fails.
dbManager | A pointer to the DB::DatabaseManager instance used for checking the connection. |
Referenced by CreateNewUserRequest::execute(), DeleteUserRequest::execute(), GetAccountNumberRequest::execute(), GetBalanceRequest::execute(), GetDatabaseRequest::execute(), GetTransactionsHistoryRequest::execute(), LoginRequest::execute(), MakeTransactionRequest::execute(), UpdateEmailRequest::execute(), UpdatePasswordRequest::execute(), UpdateUserRequest::execute(), and UserInitRequest::execute().