REST-сервис для управления заказами на Spring Boot.
- Java 21
- Spring Boot 3
- Spring Web
- Spring Data JPA
- Spring Cloud OpenFeign
- Spring AMQP (RabbitMQ)
- H2 (in-memory)
- Flyway
- Resilience4j (Retry, RateLimiter, Bulkhead, Circuit Breaker)
- Swagger/OpenAPI (
springdoc)
./gradlew bootRunСервис стартует на http://localhost:8081.
- Swagger UI:
http://localhost:8081/swagger-ui/index.html - OpenAPI JSON:
http://localhost:8081/v3/api-docs - H2 Console:
http://localhost:8081/h2-console- JDBC URL:
jdbc:h2:mem:orderdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE - User:
sa - Password: (пусто)
- JDBC URL:
Миграции лежат в src/main/resources/db/migration.
При старте приложения выполняется V1__init_schema.sql.
Базовый путь: /api/orders
curl -X POST "http://localhost:8081/api/orders" \
-H "Content-Type: application/json" \
-d '{
"customerId": 101,
"status": "NEW",
"shippingAddress": {
"street": "Lenina 1",
"city": "Moscow",
"postalCode": "101000",
"country": "Russia"
},
"items": [
{
"productName": "Phone",
"quantity": 1,
"price": {
"amount": 49999.99,
"currency": "RUB"
}
},
{
"productName": "Case",
"quantity": 2,
"price": {
"amount": 999.50,
"currency": "RUB"
}
}
]
}'curl "http://localhost:8081/api/orders"curl "http://localhost:8081/api/orders/1"curl -X PUT "http://localhost:8081/api/orders/1" \
-H "Content-Type: application/json" \
-d '{
"customerId": 101,
"status": "CONFIRMED",
"shippingAddress": {
"street": "Lenina 1",
"city": "Moscow",
"postalCode": "101000",
"country": "Russia"
},
"items": [
{
"productName": "Phone",
"quantity": 1,
"price": {
"amount": 48999.99,
"currency": "RUB"
}
}
]
}'curl -X DELETE "http://localhost:8081/api/orders/1"curl -X POST "http://localhost:8081/api/orders/1/payment" \
-H "Content-Type: application/json" \
-d '{
"method": "CARD"
}'curl -X POST "http://localhost:8081/api/orders/1/payment/async" \
-H "Content-Type: application/json" \
-d '{
"method": "CARD"
}'./gradlew clean bootJar
docker build -t order-service .
docker run --rm -p 8081:8081 order-service./gradlew clean bootJar
docker compose up --buildПоднимаются:
order-serviceна8081rabbitmqна5673(внутри сети Docker:5672)- RabbitMQ UI на
15673
CLIENTS_PAYMENT_SERVICE_URL(default:http://localhost:8082)RABBITMQ_HOST(default:localhost)RABBITMQ_PORT(default:5672)RABBITMQ_USERNAME(default:admin)RABBITMQ_PASSWORD(default:admin)