Banking_System_Server  1.0.0
Qt-based banking app for user/admin account management, transactions, secure server communication via PostgreSQL/Supabase.
Request Class Referenceabstract

The Request class is an abstract base class for handling different types of requests. More...

#include <Request.h>

Inheritance diagram for Request:
Inheritance graph
Collaboration diagram for Request:
Collaboration graph

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ~Request()

virtual Request::~Request ( )
inlinevirtual

Virtual destructor for the Request class.

Ensures proper cleanup of derived classes.

Member Function Documentation

◆ CreateDBConnectionError()

QJsonObject Request::CreateDBConnectionError ( QJsonObject &  response,
QJsonObject &  dataObj 
)
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.

Parameters
responseA reference to the QJsonObject that will be populated with the error response.
dataObjA reference to the QJsonObject that contains additional data about the error.
Returns
The updated QJsonObject containing the error 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().

Here is the caller graph for this function:

◆ CreateErrorResponse()

QJsonObject Request::CreateErrorResponse ( QJsonObject &  response,
QJsonObject &  dataObj,
QString  message 
)
inlineprotected

Creates a generic error JSON response.

This method constructs a JSON response object with a status of false and a custom error message.

Parameters
responseA reference to the QJsonObject that will be populated with the error response.
dataObjA reference to the QJsonObject that contains additional data about the error.
messageA QString containing the error message to include in the response.
Returns
The updated QJsonObject containing the error 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().

Here is the caller graph for this function:

◆ execute()

virtual QJsonObject Request::execute ( const QJsonObject &  jsonObj,
QMutex &  m 
)
pure virtual

Pure virtual method to execute a request.

This method must be implemented by derived classes to handle specific types of requests.

Parameters
jsonObjA QJsonObject containing the request data.
mA QMutex reference for thread-safe operations.
Returns
A QJsonObject containing the response data.

Implemented in UserInitRequest, UpdateUserRequest, UpdatePasswordRequest, UpdateEmailRequest, MakeTransactionRequest, LoginRequest, GetTransactionsHistoryRequest, GetDatabaseRequest, GetBalanceRequest, GetAccountNumberRequest, DeleteUserRequest, and CreateNewUserRequest.

◆ isDBConnectionValid()

bool Request::isDBConnectionValid ( DB::DatabaseManager dbManager)
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.

Parameters
dbManagerA pointer to the DB::DatabaseManager instance used for checking the connection.
Returns
True if the database connection is valid, false otherwise.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: