aboutsummaryrefslogtreecommitdiff
path: root/order-service/app/api
diff options
context:
space:
mode:
authoralex <[email protected]>2026-07-16 15:16:23 +0200
committeralex <[email protected]>2026-07-16 15:16:23 +0200
commit5f6918db393ed78dd8f038e9e5f1ea85f811dc52 (patch)
treea848c30dc4bb3fafd1e42b202b438e3aa7f9b51e /order-service/app/api
parent0c3cfccd9c1d5e5eefad813001c31d79e93aca1a (diff)
downloadorder-inventory-system-5f6918db393ed78dd8f038e9e5f1ea85f811dc52.tar.xz
order-inventory-system-5f6918db393ed78dd8f038e9e5f1ea85f811dc52.zip
added get for orders query
Diffstat (limited to 'order-service/app/api')
-rw-r--r--order-service/app/api/v1/endpoints/orders.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/order-service/app/api/v1/endpoints/orders.py b/order-service/app/api/v1/endpoints/orders.py
index beff480..934e7d5 100644
--- a/order-service/app/api/v1/endpoints/orders.py
+++ b/order-service/app/api/v1/endpoints/orders.py
@@ -1,6 +1,7 @@
from decimal import Decimal
from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy.orm import Session
+from typing import List
from app.api import deps
from app.models.order import Order, OrderItem
@@ -73,3 +74,18 @@ def read_order(order_id: int, db: Session = Depends(deps.get_db)):
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail="Could not read the order.",
)
+
+
[email protected]("/", response_model=List[OrderOut])
+def list_orders(skip: int = 0, limit: int = 100, db: Session = Depends(deps.get_db)):
+ try:
+ orders = db.query(Order).offset(skip).limit(limit).all()
+ return orders
+
+ except Exception as e:
+ db.rollback()
+ print(e)
+ raise HTTPException(
+ status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
+ detail="Could not read the order.",
+ )