48 lines
1.8 KiB
Python
48 lines
1.8 KiB
Python
from fastapi.routing import APIRouter
|
|
from fastapi.requests import Request
|
|
|
|
from api_validations.validations_request import (
|
|
DepartmentsPydantic,
|
|
PatchRecord,
|
|
ListOptions,
|
|
)
|
|
from ApiServices.api_handlers.auth_actions.token import parse_token_object_to_dict
|
|
|
|
|
|
department_route = APIRouter(prefix="/department", tags=["Departments"])
|
|
department_route.include_router(department_route, include_in_schema=True)
|
|
|
|
|
|
@department_route.post(path="/list", summary="List Active/Delete/Confirm Departments")
|
|
def company_department_list(request: Request, list_options: ListOptions):
|
|
token_dict = parse_token_object_to_dict(request=request)
|
|
return token_dict.available_event(list_options=list_options, token_dict=token_dict)
|
|
|
|
|
|
@department_route.post(path="/create", summary="Create Company with given auth levels")
|
|
def company_department_create(request: Request, data: DepartmentsPydantic):
|
|
token_dict = parse_token_object_to_dict(request=request)
|
|
return token_dict.available_event(data=data, token_dict=token_dict)
|
|
|
|
|
|
@department_route.post(
|
|
path="/update/{company_uu_id}", summary="Update Company with given auth levels"
|
|
)
|
|
def company_department_update(
|
|
request: Request, company_uu_id: str, data: DepartmentsPydantic
|
|
):
|
|
token_dict = parse_token_object_to_dict(request=request)
|
|
return token_dict.available_event(
|
|
company_uu_id=company_uu_id, data=data, token_dict=token_dict
|
|
)
|
|
|
|
|
|
@department_route.patch(
|
|
path="/patch/{company_uu_id}", summary="Patch Company with given auth levels"
|
|
)
|
|
def company_department_patch(request: Request, company_uu_id: str, data: PatchRecord):
|
|
token_dict = parse_token_object_to_dict(request=request)
|
|
return token_dict.available_event(
|
|
company_uu_id=company_uu_id, data=data, token_dict=token_dict
|
|
)
|