Requisitos: Java 17+, Maven.
Construir todo:
mvn -T 1C clean installCorrer test unitarios:
mvn test Correr módulos individualmente (desde cada carpeta):
mvn spring-boot:runORDER BD
- http://localhost:8082/h2-console (jdbc url: jdbc:h2:mem:ordersdb)
- Usuario: devUser
- Password:devU$ER2025
PRODUCT BD
- http://localhost:8081/h2-console (jdbc url: jdbc:h2:mem:productsdb)
- Usuario: devUser
- Password: dev2025
Para ambiente productivo debe estar desactivado
PRODUCT-SERVICE http://localhost:8081/swagger-ui/index.html
ORDER-SERVICE http://localhost:8082/swagger-ui/index.html
- PARA PROBAR LOS CURLS SE PUEDE USAR POSTMAN E IRLOS IMPORTANDO.
- TAMBIEN SE PUEDE USAR LA INTERFAZ GRAFICA DE SWAGGER EN LA SECCION DE DOCUMENTACION DE APIS ESTAN LOS LINKS DE ACCESO
- EN CASO DE NO USAR SWAGGER DEJO LOS PASOS Y CURLS A SEGUIR 1-crear uno o varios productos con la siguiente curl , en caso contrario utilizar la interfaz grafica que provee Swagger para probar los servicios:
CURL PARA CREAR PRODUCTOS
curl -X 'POST'
'http://localhost:8081/api/products'
-H 'accept: /'
-H 'Content-Type: application/json'
-d '{
"id": 1,
"name": "REDBULL",
"price": 23.09,
"stock": 12,
"active": true
}'
2-cONSULTAR EL QUE EL PRODUCTO SE ALMACENO EN LA BASE DE DATOS CON LA CURL QUE OBTIENE TODOS LOS PRODUCTOS
curl -X 'GET'
'http://localhost:8081/api/products'
-H 'accept: /'
2.1 Y SI SE SABE EL ID PUEDES BUSCAR POR ID, REEMPLAZAR POR EL ID QUE QUIERES ENCONTRAR
curl -X 'GET'
'http://localhost:8081/api/products/1'
-H 'accept: /'
3-para verificar disponibilidad de un producto se debe incluir el id del producto,precio unitario y cantidad de productos que se quieren para saber si hay stock ,
curl -X 'POST'
'http://localhost:8081/api/products/check-availability'
-H 'accept: /'
-H 'Content-Type: application/json'
-d '[
{
"productId": 1,
"quantity": 2,
"unitPrice": 23.09
},
]'
//CREACION DE PEDIDOS
4-PARA CREAR UNA ORDEN DE UN PRODUCTO EN ESPECIFICO SE UTILIZA LA CURLS
curl -X 'POST'
'http://localhost:8082/api/orders'
-H 'accept: /'
-H 'Content-Type: application/json'
-d '{
"customerName": "MIGUELSTACK",
"customerEmail": "SASKE.MADARA@GMAIL.COM",
"orderDate": "2025-10-11T05:27:15.553",
"status": "CONFIRMED",
"totalAmount": 46.18,
"items": [
{
"productId": 1,
"quantity": 2,
"unitPrice": 23.09
}
]
}'
SI LA ORDEN PROCEDE PORQUE HAY DISPONIBILIDAD SE ESPERA UNA RESPUESTA COMO POR EJEMPLO:
{ "id": 1, "customerName": "MIGUELSTACK", "customerEmail": "SASKE.MADARA@GMAIL.COM", "orderDate": "2025-10-11T05:27:15.553", "status": "CONFIRMED", "totalAmount": 46.18, "items": [ { "id": 1, "productId": 1, "quantity": 2, "unitPrice": 23.09 } ] }
5 - PARA CONSULTAR UNA ORDEN POR ID SE USA :
curl -X 'GET'
'http://localhost:8082/api/orders/1'
-H 'accept: /'
6- TAMBIEN PODEMOS CONSULTAR TODOS LOS PEDIDOS
curl -X 'GET'
'http://localhost:8082/api/orders'
-H 'accept: /'