database and services updated and tested
This commit is contained in:
@@ -5,20 +5,21 @@ ENV PYTHONUNBUFFERED 1
|
||||
|
||||
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
|
||||
|
||||
COPY ../service_app/requirements.txt .
|
||||
COPY ApiServices/AuthService/pyproject.toml .
|
||||
|
||||
RUN uv venv
|
||||
RUN uv pip install -r requirements.txt
|
||||
RUN uv pip install -r pyproject.toml
|
||||
|
||||
COPY ../service_app ./service_app
|
||||
COPY ApiServices/AuthService ./service_app
|
||||
COPY ApiServices/api_handlers ./service_app/api_handlers
|
||||
|
||||
COPY ../databases ./service_app/databases
|
||||
COPY ../api_services ./service_app/api_services
|
||||
COPY ../api_objects ./service_app/api_objects
|
||||
COPY ../api_configs ./service_app/api_configs
|
||||
COPY ../api_events ./service_app/api_events
|
||||
COPY ../api_library ./service_app/api_library
|
||||
COPY ../api_validations ./service_app/api_validations
|
||||
COPY databases ./service_app/databases
|
||||
COPY api_services ./service_app/api_services
|
||||
COPY api_objects ./service_app/api_objects
|
||||
COPY api_configs ./service_app/api_configs
|
||||
COPY api_events ./service_app/api_events
|
||||
COPY api_library ./service_app/api_library
|
||||
COPY api_validations ./service_app/api_validations
|
||||
|
||||
WORKDIR /service_app
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi.openapi.utils import get_openapi
|
||||
from fastapi.responses import RedirectResponse
|
||||
from api_configs.configs import Config
|
||||
|
||||
|
||||
def create_app(routers):
|
||||
from fastapi import FastAPI
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi.openapi.utils import get_openapi
|
||||
from fastapi.responses import RedirectResponse
|
||||
|
||||
from api_configs import Config
|
||||
|
||||
api_app = FastAPI(title=str(Config.TITLE), default_response_class=JSONResponse)
|
||||
|
||||
@api_app.get("/", include_in_schema=False, summary=str(Config.DESCRIPTION))
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
__all__ = []
|
||||
|
||||
@@ -5,20 +5,21 @@ ENV PYTHONUNBUFFERED 1
|
||||
|
||||
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
|
||||
|
||||
COPY ../service_app/requirements.txt .
|
||||
COPY ApiServices/EventService/pyproject.toml .
|
||||
|
||||
RUN uv venv
|
||||
RUN uv pip install -r requirements.txt
|
||||
RUN uv pip install -r pyproject.toml
|
||||
|
||||
COPY ../service_app ./service_app
|
||||
COPY ApiServices/EventService ./service_app
|
||||
COPY ApiServices/api_handlers ./service_app/api_handlers
|
||||
|
||||
COPY ../databases ./service_app/databases
|
||||
COPY ../api_services ./service_app/api_services
|
||||
COPY ../api_objects ./service_app/api_objects
|
||||
COPY ../api_configs ./service_app/api_configs
|
||||
COPY ../api_events ./service_app/api_events
|
||||
COPY ../api_library ./service_app/api_library
|
||||
COPY ../api_validations ./service_app/api_validations
|
||||
COPY databases ./service_app/databases
|
||||
COPY api_services ./service_app/api_services
|
||||
COPY api_objects ./service_app/api_objects
|
||||
COPY api_configs ./service_app/api_configs
|
||||
COPY api_events ./service_app/api_events
|
||||
COPY api_library ./service_app/api_library
|
||||
COPY api_validations ./service_app/api_validations
|
||||
|
||||
WORKDIR /service_app
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
__all__ = []
|
||||
@@ -5,20 +5,21 @@ ENV PYTHONUNBUFFERED 1
|
||||
|
||||
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
|
||||
|
||||
COPY ../service_app/requirements.txt .
|
||||
COPY ApiServices/ValidationService/pyproject.toml .
|
||||
|
||||
RUN uv venv
|
||||
RUN uv pip install -r requirements.txt
|
||||
RUN uv pip install -r pyproject.toml
|
||||
|
||||
COPY ../service_app ./service_app
|
||||
COPY ApiServices/ValidationService ./service_app
|
||||
COPY ApiServices/api_handlers ./service_app/api_handlers
|
||||
|
||||
COPY ../databases ./service_app/databases
|
||||
COPY ../api_services ./service_app/api_services
|
||||
COPY ../api_objects ./service_app/api_objects
|
||||
COPY ../api_configs ./service_app/api_configs
|
||||
COPY ../api_events ./service_app/api_events
|
||||
COPY ../api_library ./service_app/api_library
|
||||
COPY ../api_validations ./service_app/api_validations
|
||||
COPY databases ./service_app/databases
|
||||
COPY api_services ./service_app/api_services
|
||||
COPY api_objects ./service_app/api_objects
|
||||
COPY api_configs ./service_app/api_configs
|
||||
COPY api_events ./service_app/api_events
|
||||
COPY api_library ./service_app/api_library
|
||||
COPY api_validations ./service_app/api_validations
|
||||
|
||||
WORKDIR /service_app
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
__all__ = []
|
||||
|
||||
0
ApiServices/__init__.py
Normal file
0
ApiServices/__init__.py
Normal file
0
ApiServices/api_handlers/__init__.py
Normal file
0
ApiServices/api_handlers/__init__.py
Normal file
147
ApiServices/api_handlers/core_response.py
Normal file
147
ApiServices/api_handlers/core_response.py
Normal file
@@ -0,0 +1,147 @@
|
||||
from typing import Any, Union
|
||||
from fastapi import status
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from databases.sql_models.response_model import AlchemyResponse
|
||||
|
||||
|
||||
class AlchemyJsonResponse:
|
||||
status_code: status
|
||||
message: str
|
||||
result: AlchemyResponse
|
||||
completed: bool
|
||||
filter_attributes: Any = None
|
||||
response_model: Any = None
|
||||
cls_object: Any = None
|
||||
|
||||
@staticmethod
|
||||
def get_total_count(cls_object, filter_attributes):
|
||||
total_page_number = 1
|
||||
count_to_use = cls_object.total_count / int(filter_attributes.size)
|
||||
if cls_object.total_count > int(filter_attributes.size):
|
||||
if isinstance(count_to_use, int):
|
||||
total_page_number = round(count_to_use, 0)
|
||||
elif isinstance(count_to_use, float):
|
||||
total_page_number = round(count_to_use, 0) + 1
|
||||
return total_page_number
|
||||
|
||||
def __new__(
|
||||
cls,
|
||||
message: str,
|
||||
status_code: str = "HTTP_200_OK",
|
||||
result: Union[Any, list] = None,
|
||||
completed: bool = True,
|
||||
response_model: Any = None,
|
||||
cls_object: Any = None,
|
||||
filter_attributes: Any = None,
|
||||
):
|
||||
cls.status_code = getattr(status, status_code, "HTTP_200_OK")
|
||||
cls.message = message
|
||||
cls.result = result
|
||||
cls.completed = completed
|
||||
cls.response_model = response_model
|
||||
|
||||
pagination_dict = {
|
||||
"size/total_count": [10, 10],
|
||||
"page/total_page": [1, 1],
|
||||
"order_field": "id",
|
||||
"order_type": "asc",
|
||||
}
|
||||
if filter_attributes:
|
||||
total_page_number = cls.get_total_count(cls_object, filter_attributes)
|
||||
pagination_dict = {
|
||||
"size/total_count": [filter_attributes.size, cls_object.total_count],
|
||||
"page/total_page": [filter_attributes.page, total_page_number],
|
||||
"order_field": filter_attributes.order_field,
|
||||
"order_type": filter_attributes.order_type,
|
||||
}
|
||||
|
||||
if isinstance(cls.result, dict) or isinstance(cls.result, list):
|
||||
return JSONResponse(
|
||||
status_code=cls.status_code,
|
||||
content=dict(
|
||||
total_count=len(cls.result),
|
||||
count=len(cls.result),
|
||||
pagination=pagination_dict,
|
||||
completed=cls.completed,
|
||||
message=cls.message,
|
||||
data=cls.result,
|
||||
),
|
||||
)
|
||||
|
||||
first_item = getattr(cls.result, "data", None)
|
||||
if not first_item:
|
||||
return JSONResponse(
|
||||
status_code=cls.status_code,
|
||||
content=dict(
|
||||
total_count=0,
|
||||
count=0,
|
||||
pagination=pagination_dict,
|
||||
completed=cls.completed,
|
||||
message=cls.message,
|
||||
data=[],
|
||||
),
|
||||
)
|
||||
|
||||
if cls.result.first:
|
||||
return JSONResponse(
|
||||
status_code=cls.status_code,
|
||||
content=dict(
|
||||
total_count=1,
|
||||
count=1,
|
||||
pagination=pagination_dict,
|
||||
completed=cls.completed,
|
||||
message=cls.message,
|
||||
data=cls.result.data.get_dict(),
|
||||
),
|
||||
)
|
||||
|
||||
if not cls.result.get(1).filter_attr and isinstance(cls.result.data, list):
|
||||
counts = cls.result.count
|
||||
return JSONResponse(
|
||||
status_code=cls.status_code,
|
||||
content=dict(
|
||||
total_count=counts,
|
||||
count=counts,
|
||||
pagination=pagination_dict,
|
||||
completed=cls.completed,
|
||||
message=cls.message,
|
||||
data=[result_data.get_dict() for result_data in cls.result.data],
|
||||
),
|
||||
)
|
||||
|
||||
# filter_model = cls.result.get(1).filter_attr
|
||||
total_count = cls.result.get(1).query.limit(None).offset(None).count()
|
||||
total_page_number = cls.get_total_count(cls_object, filter_attributes)
|
||||
pagination_dict = {
|
||||
"size/total_count": [filter_attributes.size, cls_object.total_count],
|
||||
"page/total_page": [filter_attributes.page, total_page_number],
|
||||
"order_field": filter_attributes.order_field,
|
||||
"order_type": filter_attributes.order_type,
|
||||
}
|
||||
include_joins = dict(
|
||||
include_joins=(
|
||||
filter_attributes.include_joins
|
||||
if filter_attributes.include_joins
|
||||
else []
|
||||
)
|
||||
)
|
||||
data = []
|
||||
for data_object in cls.result.data:
|
||||
data_dict = data_object.get_dict(include_joins=include_joins)
|
||||
if cls.response_model:
|
||||
data_dict = cls.response_model(
|
||||
**data_object.get_dict(include_joins=include_joins)
|
||||
).dump()
|
||||
data.append(data_dict)
|
||||
return JSONResponse(
|
||||
status_code=cls.status_code,
|
||||
content=dict(
|
||||
total_count=total_count or 1,
|
||||
count=cls.result.count,
|
||||
pagination=pagination_dict,
|
||||
message=cls.message,
|
||||
completed=cls.completed,
|
||||
data=data,
|
||||
),
|
||||
)
|
||||
@@ -1,29 +0,0 @@
|
||||
services:
|
||||
|
||||
wag_management_auth_service:
|
||||
container_name: wag_management_auth_service
|
||||
restart: on-failure
|
||||
build:
|
||||
context: .
|
||||
dockerfile: AuthService/Dockerfile
|
||||
ports:
|
||||
- "11:41575"
|
||||
|
||||
wag_management_event_service:
|
||||
container_name: wag_management_event_service
|
||||
restart: on-failure
|
||||
build:
|
||||
context: .
|
||||
dockerfile: EventService/Dockerfile
|
||||
ports:
|
||||
- "12:41575"
|
||||
|
||||
wag_management_validation_service:
|
||||
container_name: wag_management_validation_service
|
||||
restart: on-failure
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ValidationService/Dockerfile
|
||||
ports:
|
||||
- "13:41575"
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
services:
|
||||
|
||||
wag_management_auth_service:
|
||||
container_name: wag_management_auth_service
|
||||
restart: on-failure
|
||||
build:
|
||||
context: .
|
||||
dockerfile: AuthService/Dockerfile
|
||||
ports:
|
||||
- "11:41575"
|
||||
|
||||
wag_management_event_service:
|
||||
container_name: wag_management_event_service
|
||||
restart: on-failure
|
||||
build:
|
||||
context: .
|
||||
dockerfile: EventService/Dockerfile
|
||||
ports:
|
||||
- "12:41575"
|
||||
|
||||
wag_management_validation_service:
|
||||
container_name: wag_management_validation_service
|
||||
restart: on-failure
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ValidationService/Dockerfile
|
||||
ports:
|
||||
- "13:41575"
|
||||
|
||||
Reference in New Issue
Block a user