📑📑

Order Service

Stack

Golang
PostgreSQL

Use Case

Order Creation:
When a user places an order, the Order Service receives the UserID, ProductID, Quantity, and TotalPrice.
The Order Service generates a unique ID for the order.
It validates the provided UserID and ProductID to ensure they correspond to existing records.
The Order Service calculates the TotalPrice based on the Quantity and stores the order's ID, UserID, ProductID, Quantity, TotalPrice, and an initial Status (e.g., "Pending") in the PostgreSQL database.
Order Modification:
The Order Service provides functionality to modify orders, such as updating the Quantity or changing the Status.
When a modification request is received, the Order Service retrieves the relevant order record from the PostgreSQL database based on the order's ID.
It performs the necessary validations or checks before applying the requested modifications.
The Order Service updates the corresponding fields in the order record and saves the changes back to the PostgreSQL database.
Order Retrieval:
The Order Service provides methods to retrieve order information based on various criteria, such as UserID or order ID.
When a retrieval request is received, the Order Service queries the PostgreSQL database using the specified criteria.
It retrieves the relevant order records and returns the requested order information to the user, which may include details like OrderID, UserID, ProductID, Quantity, TotalPrice, and Status.

Data Structure

Order Service (PostgreSQL):
Order:
ID (int)
UserID (int)
ProductID (int)
Quantity (int)
TotalPrice (float)
Status (string)