2 chained application designed and new stage inited

This commit is contained in:
2025-06-24 12:41:06 +03:00
parent 311736ce06
commit a9655c5f48
45 changed files with 3090 additions and 386 deletions

View File

@@ -1,5 +1,6 @@
from typing import Any
from typing import Any, Optional
from fastapi import APIRouter, Depends
from pydantic import BaseModel
from index import endpoints_index
from events.builds.cluster import BuildRouterCluster
@@ -9,6 +10,31 @@ from Validations.response.pagination import PaginateOnly
from Extensions.Middlewares.token_provider import TokenProvider
# Pydantic model for build update validation
class BuildFormModel(BaseModel):
gov_address_code: str
build_name: str
build_no: str
max_floor: int
underground_floor: int
build_date: str
decision_period_date: str
tax_no: str
lift_count: int
heating_system: bool
cooling_system: bool
hot_water_system: bool
block_service_man_count: int
security_service_man_count: int
garage_count: int
site_uu_id: Optional[str] = None
address_uu_id: str
build_types_uu_id: str
class Config:
extra = "allow"
build_endpoint_route = APIRouter(prefix="/builds", tags=["Builds Cluster"])
build_list = "BuildList"
@@ -21,7 +47,7 @@ def build_list_route(data: PaginateOnly, headers: CommonHeaders = Depends(Common
token_object = TokenProvider.get_dict_from_redis(token=headers.token)
event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object)
event_key = TokenProvider.retrieve_event_codes(**event_founder_dict)
FoundCluster = BuildRouterCluster.get_event_cluster(build_list)
FoundCluster = BuildRouterCluster.get_event_cluster("BuildListEventCluster")
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
return event_cluster_matched.event_callable(list_options=data, headers=headers)
@@ -32,11 +58,11 @@ build_create = "BuildCreate"
description="Create build endpoint",
operation_id=endpoints_index[build_create],
)
def build_create_route(data, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)):
def build_create_route(data: BuildFormModel, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)):
token_object = TokenProvider.get_dict_from_redis(token=headers.token)
event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object)
event_key = TokenProvider.retrieve_event_codes(**event_founder_dict)
FoundCluster = BuildRouterCluster.get_event_cluster(build_create)
FoundCluster = BuildRouterCluster.get_event_cluster("BuildCreateEventCluster")
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
return event_cluster_matched.event_callable(data=data, headers=headers)
@@ -47,11 +73,11 @@ build_update = "BuildUpdate"
description="Update build endpoint",
operation_id=endpoints_index[build_update],
)
def build_update_route(uu_id: str, data, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)):
def build_update_route(uu_id: str, data: BuildFormModel, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)):
token_object = TokenProvider.get_dict_from_redis(token=headers.token)
event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object)
event_key = TokenProvider.retrieve_event_codes(**event_founder_dict)
FoundCluster = BuildRouterCluster.get_event_cluster(build_update)
FoundCluster = BuildRouterCluster.get_event_cluster("BuildUpdateEventCluster")
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
return event_cluster_matched.event_callable(uu_id=uu_id, data=data, headers=headers)