This is a backend service for managing customer orders, products, and stock levels. It provides functionalities such as adding products, placing orders, and updating order items with stock validation.
- Backend: Java, Spring Boot, Spring Security
- Database: MySQL
- API Testing: Postman
- Add a new product 🆕
- Update product details ✏️
- Delete products ❌
- View all products 📋
- Filter products by category 📂
- Filter products by price range 💰
- Search products by name 🔎
- Check stock quantity of a product 📦
- Role-based access control (RBAC) 🔑
- Admin-only routes for product management 👨💼
- Install Java 17+
- Install MySQL
- Install Postman (for API testing)
-
Clone the repository:
git clone https://github.com/ruturajjadhav07/Customer-Order-Backend.git cd Customer-Order-Backend
-
Configure Database:
- Create a MySQL database named
order_cart
. - Update
application.properties
with your database credentials.
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.url=jdbc:mysql://localhost:3306/order_cart spring.datasource.username=username spring.datasource.password=password spring.jpa.show-sql=true spring.jpa.hibernate.ddl-auto=update
- Create a MySQL database named
-
Run the application:
mvn spring-boot:run
-
Build & Run the Application
mvn spring-boot:run
POST /register
→ Register a new customerPOST /login
→ Login customerGET /customer/{id}
→ Get customer details (only for logged-in user)PUT /customer/update/{id}
→ Update customer details (only for logged-in user)DELETE /customer/delete/{id}
→ Delete customer (only for logged-in user)GET /admin/customers
→ Get all customers (only for Admins)
POST /customer/order
→ Place an orderGET /customer/orders/{id}
→ Get order details by IDGET /customer/orders/{customerId}/orders
→ Get all orders of a specific customerDELETE /customer/order/{customerId}/{orderId}
→ Delete an order (only for the customer)GET /customer/admin/allorders
→ Get all orders (only for Admins)
POST /products/admin/add
→ Add a product (only for Admins)GET /products
→ Get all productsGET /products/category?category={category}
→ Get products by categoryGET /products/price-range?minPrice={min}&maxPrice={max}
→ Get products within a price rangeGET /products/search?name={name}
→ Search products by nameGET /products/{id}/quantity
→ Check stock quantity of a productPUT /products/admin/update/{id}
→ Update product details (only for Admins)DELETE /products/admin/delete/{id}
→ Delete a product (only for Admins)
GET /order-items/{customer_id}/{order_id}/{product_id}
→ Fetch order details by user IDPUT /order-items/customer/{customerId}/order/{orderId}/orderitem/{orderItemId}/update?addOnQuantity={quantity}
→ Update order item quantity
Request:
{
"name": "Ruturaj Jadhav",
"email": "ruturajjadhav122@gmail.com",
"password": "*********",
"address": "Pune",
"phoneNumber": "123456789",
"role": "USER"
}
Request:
{
"email": "ruturajjadhav122@gmail.com",
"password": "*********"
}
Request:
{
"productName": "Laptop",
"productPrice": 1200.50,
"productDescription": "High-performance laptop",
"productCategory": "Electronics",
"productQuantity": 10
}
- Spring Boot: Official Documentation
- Spring Security: Official Documentation
This project is licensed under the MIT License - see the LICENSE file for details.