added get order status

parent 889a6da3
......@@ -26,3 +26,10 @@ class OrderController(BaseController):
except common_exc.UpdateException as e:
raise http_exc.HTTPBadRequestException(detail=str(e))
async def get_order_status(self, id: UUID):
try:
return await self.order_service.get_order_status(id)
except common_exc.NotFoundException as e:
raise http_exc.HTTPNotFoundException(detail=str(e))
from uuid import UUID
import fastapi as fa
from .ctrl import OrderController
......@@ -17,3 +19,9 @@ async def create_order(body: OrderPostSchema):
async def accepted_order(body: OrderIdSchema):
order = await ctrl.accepted_order(**body.model_dump(exclude_none=True))
return OrderStatusSchema.model_validate(order)
@router.get('/{id}/status')
async def get_order_status(id: UUID):
order = await ctrl.get_order_status(id)
return OrderStatusSchema.model_validate(order)
......@@ -53,3 +53,7 @@ class OrderService:
await order.save()
return {'id': order.id, 'status': order.status}
async def get_order_status(self, id: UUID):
order = await self.order_repository.get(id)
return {'id': order.id, 'status': order.status}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment