A dedicated microservice in the E-Commerce system responsible for managing product pricing, including base prices and discounts. This service supports pricing persistence and calculates discounted prices on demand.
The Price Service enables CRUD operations on product pricing and integrates with the Product Service using RESTful APIs. It stores base price and discount percentage for each product and exposes endpoints to fetch both raw and discounted price data.
- Language: Java 17+
- Framework: Spring Boot
- Database: H2 (In-memory) / MySQL
- Tools: Maven, Lombok
- Communication: REST (Spring Web)
com.example.demo
βββ controller
β βββ Controllerprice.java
βββ dto
β βββ Pricedto.java
βββ model
β βββ Price.java
βββ repository
β βββ PriceRepository.java
βββ service
β βββ PriceService.java
β βββ PriceServiceImpl.java
βββ DemoApplication.java
POST /price
Registers a new price for a product.
Request Body:
{
"productId": 1,
"basePrice": 999.99,
"discountPercent": 10.0
}
###2. Get Price by Product ID
**GET** /price/{productId}
Returns the base price and discount percentage for a given product.
Sample Response:
**Request Body**:
```json
{
"productId": 1,
"basePrice": 999.99,
"discountPercent": 10.0
}