UPDATE
This commit is contained in:
+14
-4
@@ -28,7 +28,7 @@ class EconomicOverviewView(APIView):
|
||||
@extend_schema(
|
||||
tags=["Economy"],
|
||||
summary="دریافت نمای اقتصادی مزرعه",
|
||||
description="با دریافت farm_uuid، نمای اقتصادی مزرعه را فعلا با داده mock برمی گرداند.",
|
||||
description="با دریافت farm_uuid، نمای اقتصادی مزرعه را از منبع واقعی برمی گرداند.",
|
||||
request=EconomicOverviewRequestSerializer,
|
||||
responses={
|
||||
200: build_response(
|
||||
@@ -39,6 +39,10 @@ class EconomicOverviewView(APIView):
|
||||
EconomyErrorSerializer,
|
||||
"داده ورودی نامعتبر است.",
|
||||
),
|
||||
503: build_response(
|
||||
EconomyErrorSerializer,
|
||||
"منبع داده نمای اقتصادی در دسترس نیست.",
|
||||
),
|
||||
},
|
||||
examples=[
|
||||
OpenApiExample(
|
||||
@@ -57,9 +61,15 @@ class EconomicOverviewView(APIView):
|
||||
)
|
||||
|
||||
service = apps.get_app_config("economy").get_economic_overview_service()
|
||||
data = service.get_economic_overview(
|
||||
farm_uuid=str(serializer.validated_data["farm_uuid"])
|
||||
)
|
||||
try:
|
||||
data = service.get_economic_overview(
|
||||
farm_uuid=str(serializer.validated_data["farm_uuid"])
|
||||
)
|
||||
except NotImplementedError as exc:
|
||||
return Response(
|
||||
{"code": 503, "msg": str(exc), "data": None},
|
||||
status=status.HTTP_503_SERVICE_UNAVAILABLE,
|
||||
)
|
||||
return Response(
|
||||
{"code": 200, "msg": "success", "data": data},
|
||||
status=status.HTTP_200_OK,
|
||||
|
||||
Reference in New Issue
Block a user